In: Computer Science
In Python
Which initial value of x will make the following piece of code
leave a 9 in the final value of x?
x = ____?
if x < 7:
   x = x + 1
x = x + 2
| a. | 
 11  | 
|
| b. | 
 9  | 
|
| c. | 
 7  | 
|
| d. | 
 None of the above  | 
Which initial value of x will make the following piece of code
leave a 20 in the final value of x?
x = ____?
if x * 2 <= 34:
   x = 0
else:
   x = x + 1
x = x + 1
| a. | 
 17  | 
|
| b. | 
 18  | 
|
| c. | 
 19  | 
|
| d. | 
 20  | 
|
| e. | 
 None of the above  | 
What is a common word for the textual representation of a program?
| a. | 
 code  | 
|
| b. | 
 prompt  | 
|
| c. | 
 interpreter  | 
|
| d. | 
 expression  | 
|
| e. | 
 None of the above  | 
Which statement reads a user-entered string into variable user_name?
| a. | 
 input = user_name()  | 
|
| b. | 
 user_name = input()  | 
|
| c. | 
 input() => user_name  | 
|
| d. | 
 user_name = "input()"  | 
|
| e. | 
 None of the above  | 
What is the output?
count = 0
while count < 3:
     print('loop')
count = count + 1
print('final value of count:', count)
| a. | 
 Prints 'loop' once, then 'final value of count: 1'  | 
|
| b. | 
 Prints 'loop' three times, then 'final value of count: 3'  | 
|
| c. | 
 Prints 'loop' three times, then 'final value of count: 4'  | 
|
| d. | 
 Prints 'loop' forever (infinite loop)  | 
|
| e. | 
 None of the above  |