Quiz 1 Flashcards
How do you insert COMMENTS in Python code?
a. # This is comment
b. //This is comment
c. ! this is comment
d. /This is comment/
a. # This is comment
Which one is NOT a legal variable name?
a. var123
b. myvar_123
c. my-var
d. Myvar__
c. my-var
What is the expected behavior of the following program?
prin (“Goodbye!”)
a. The program will output (“Goodbye!”)
b. The program will generate an error message on the screen
c. The program will output “Goodbye!”
d. The program will output Goodbye!
b. The program will generate an error message on the screen
What is the output of the following code?
x = 2
y = 10
x *= y + 1
print (x)
a. 22
b. 20
c. 21
d. 11
a. 22
What is the output of the following code?
print (9//2)
a. 4.5
b. 4
c .4.0
d. Error
b. 4
How can we increment an integer variable (e.g. num=5 ) by 1?
a. num=+1
b. num=1
c. num+=1
d. num++
c. num+=1
Which of the following is TRUE for Python?
a. The not equal to operator is <>
b. The equal to operator (=) is used for comparison
c. The double equal to operators (==) is used for assignment
d. None of these
d. None of these
What is the output of the following program?
mul = 2*2
exp = 2**2
print (mul + exp)
a. None of these
b. 12
c. 8
d. 24
c. 8
Which of the following is TRUE about variables in Python? Select the best answer.
a. Variables can change in value.
b. All of these are correct.
c. The kind of data pointed by the variable can be changed later.
d. There is no need to declare the type of variable.
b. All of these are correct.
What is the output of the following code?
print (17%5)
a. 3.4
b. 4
c. 3
d. 2
d.2