Quiz 1 Flashcards

1
Q

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

a. # This is comment

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

Which one is NOT a legal variable name?

a. var123
b. myvar_123
c. my-var
d. Myvar__

A

c. my-var

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

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!

A

b. The program will generate an error message on the screen

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

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

a. 22

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

What is the output of the following code?

print (9//2)

a. 4.5
b. 4

c .4.0

d. Error

A

b. 4

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

How can we increment an integer variable (e.g. num=5 ) by 1?

a. num=+1
b. num=1
c. num+=1
d. num++

A

c. num+=1

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

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

A

d. None of these

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

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

A

c. 8

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

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.

A

b. All of these are correct.

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

What is the output of the following code?

print (17%5)

a. 3.4
b. 4
c. 3
d. 2

A

d.2

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