Which of the following is a syntax error?
Give this one a try later!
Forgetting to type a closing quotation mark for a string.
What is the output of the following valid Python code?
,x=8
if x == 3:
print('A')
elif x >= 3:
print('B')
if x <= 8:
print('C')
-C
-B
-AB
-AC
-BC
Give this one a try later!
BC
Consider the following valid Python code fragment:
if x > 4:
if x < 9:
print('W')
else:
print('X')
else:
if x < 9:
print('Y')
else:
print('Z')
For which one of the following ranges of integers would the code print Y?
- 4 through 9 (inclusive)
- any value greater than 4
- any value less than or equal to 4
- 5 through 9 (inclusive)
- any value strictly less than 9
,Give this one a try later!
any value less than or equal to 4
What is the output of the following valid Python code?
x=5
if x >= 4:
print('A')
elif x >= 3:
print('B')
else:
print('C')
-B
-BC
-A
-AB
-AC
Give this one a try later!
A
When iterating over a string, which of the following functions most directly lets you
combine the counter-driven style of for-loop with the for-each style of for-loop?
Give this one a try later!
enumerate
, Think back to the algorithm we implemented in lecture for the Caesar cipher
(encryption) algorithm. We relied on the ord and chr functions, and also on some
facts regarding the Unicode values for letters of the Latin alphabet. With all this in
mind, what is the value of y after the code below has finished executing?
x = ord('B') + 5
y = chr(x)
Give this one a try later!
'G'
B --> 2
2+ 5 = 7
7th letter = G
Suppose a Colab code cell contained only the single line of code shown below.
Assume x and y are variables created and assigned integer values in previous code
cells. What would be printed when the code cell is executed?
x=y
- Either True or False, depending on the particular values of x and y
- The new value of x
- No output
- The previous value of x
Give this one a try later!
No output
What will be the output of the program given below?
a=5
Give this one a try later!
Forgetting to type a closing quotation mark for a string.
What is the output of the following valid Python code?
,x=8
if x == 3:
print('A')
elif x >= 3:
print('B')
if x <= 8:
print('C')
-C
-B
-AB
-AC
-BC
Give this one a try later!
BC
Consider the following valid Python code fragment:
if x > 4:
if x < 9:
print('W')
else:
print('X')
else:
if x < 9:
print('Y')
else:
print('Z')
For which one of the following ranges of integers would the code print Y?
- 4 through 9 (inclusive)
- any value greater than 4
- any value less than or equal to 4
- 5 through 9 (inclusive)
- any value strictly less than 9
,Give this one a try later!
any value less than or equal to 4
What is the output of the following valid Python code?
x=5
if x >= 4:
print('A')
elif x >= 3:
print('B')
else:
print('C')
-B
-BC
-A
-AB
-AC
Give this one a try later!
A
When iterating over a string, which of the following functions most directly lets you
combine the counter-driven style of for-loop with the for-each style of for-loop?
Give this one a try later!
enumerate
, Think back to the algorithm we implemented in lecture for the Caesar cipher
(encryption) algorithm. We relied on the ord and chr functions, and also on some
facts regarding the Unicode values for letters of the Latin alphabet. With all this in
mind, what is the value of y after the code below has finished executing?
x = ord('B') + 5
y = chr(x)
Give this one a try later!
'G'
B --> 2
2+ 5 = 7
7th letter = G
Suppose a Colab code cell contained only the single line of code shown below.
Assume x and y are variables created and assigned integer values in previous code
cells. What would be printed when the code cell is executed?
x=y
- Either True or False, depending on the particular values of x and y
- The new value of x
- No output
- The previous value of x
Give this one a try later!
No output
What will be the output of the program given below?
a=5