MSBC Lesson 1-5 Flashcards
Assume the following for this question:
a = 1
b = 3
c = 2
d = 1.6
What is the value of:
a * b ** c / a
A. 1
B. 2
C. 3
D. 9
D. 9
What optional named parameter can be provided to the print() function to control what is displayed between its comma-separated items?
A. end
B. sep
C. space
D. comma
B. sep
Assume the following for this question:
a = -10.44
b = 20
c = 30
What is the value of:
min(a, max(b, c))
A.-10.44
B.20
C.30
A.-10.44
Assuming sales is a numeric variable, which is a valid statement:
A.print(round(sales,1))
B.round(print(sales), 1)
C.print(sales, round())
A.
When using the print() function, what named parameter can be used to control what is done after all items are displayed?
A. end
B. delim
C. sep
D. space
A. end
How can strings be concatenated?
A.using the + operator
B.concat() method
C.using the / operator
D.None of these
D. None of these
In a program, a specific value (such as a number or string) is referred to as a:
A.Constant
B.Keyword
C.Statement
D.Comment
A. Constant
What will the following if statement evaluate to?
if ‘This’ < ‘that’:
True
True or False, The result of an if’s logical expression can be a string.
False
True or False: The elif statement can optionally have a logical condition.
False
At the end of an if statement you must use a
A.Period
B.colon
C.semi-colon
D.comma
B. Colon
True or False: The while statement includes a condition whose result is a number.
False
True or False: Similar to while, the for statement uses a logical expression to test if its body will execute.
False
True or False: The range() function can be used together with for, to generate a sequence of float numbers.
False
The continue statement causes the program flow to move
A.Up
B.Down
C.Up or Down
D.all the options
A. Up
True or False: A function you write is executed only if a statement calls that function.
True
True or False: The statement that calls a function must use variables as the arguments for the function.
False
__________ variable is one that is not defined in any function.
A.A missing
B.an undefined
C.A local
D.A global
D. A global
What method can be used to append a list to the end of another list?
A.extend()
B.add()
C.augment()
D.concatenate
A.
Assuming the list squares is set to [1,4,9,16], what statement can be used to remove the value 1 from the list
A.alist.remove(1)
B.remove(alist,0)
C.remove(alist,1)
D.del alist.0
A.
Assuming alist is a list with 4 items, what statement can be used to remove the last item from alist and assignment the variable last to its value?
A.last = alist.pop()
B.last = alist[0]
C.last = alist[-1]
D.last = alist.drop()
A.
What statement can be used to remove the first item from a list named alist?
A.del alist[0]
B.remove(alist,0)
C.alist.remove(0)
D.del(alist,0)
A.