MSBC Lesson 1-5 Flashcards

1
Q

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

A

D. 9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

B. sep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A.-10.44

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A. end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can strings be concatenated?
A.using the + operator
B.concat() method
C.using the / operator
D.None of these

A

D. None of these

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A. Constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What will the following if statement evaluate to?

if ‘This’ < ‘that’:

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False, The result of an if’s logical expression can be a string.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True or False: The elif statement can optionally have a logical condition.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

At the end of an if statement you must use a
A.Period
B.colon
C.semi-colon
D.comma

A

B. Colon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: The while statement includes a condition whose result is a number.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

True or False: Similar to while, the for statement uses a logical expression to test if its body will execute.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False: The range() function can be used together with for, to generate a sequence of float numbers.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The continue statement causes the program flow to move
A.Up
B.Down
C.Up or Down
D.all the options

A

A. Up

17
Q

True or False: A function you write is executed only if a statement calls that function.

A

True

18
Q

True or False: The statement that calls a function must use variables as the arguments for the function.

A

False

19
Q

__________ variable is one that is not defined in any function.

A.A missing
B.an undefined
C.A local
D.A global

A

D. A global

20
Q

What method can be used to append a list to the end of another list?
A.extend()
B.add()
C.augment()
D.concatenate

A

A.

21
Q

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

A.

22
Q

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

A.

23
Q

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

A.