NEW
Font size
WorksheetsPython Quiz
Total questions: 13
Worksheet time: 7mins
What method would you use to remove whitespace from the right side of a string?
remove()
lstrip()
rstrip()
strip()
What does the expression 7 // 2 evaluate to?
1
3
3.5
4
What does the expression 7 % 2 evaluate to?
1
3
3.5
4
Which operation would you use to raise 2 to the power of 3?
2 * 3
2 ^ 3
2 ** 3
What is the result of 5 / 2 in Python?
2
2.5
2.0
3
How can you assign values 10, 20, and 30 to variables x, y, and z in one line?
assign x=10, y=20, z=30
x; y; z = 10; 20; 30
x, y, z = 10, 20, 30
x = 10, y = 20, z = 30
How do Python programmers typically indicate that a variable should be treated as a constant?
Adding an exclamation mark at the end
Putting it in parentheses
Naming it with all capital letters
Using the const keyword
What does the input() function return?
It depends on what the user enters
A string
A float
An integer
What is the result of 2 + 3 * 4?
10
14
20
24
The strip() method removes whitespace from both ends of a string.
True
False
True or False: The expression 5 / 2 in Python results in 2.
True
False
True or False: When using input(), you should always convert numerical input to the appropriate type before performing calculations.
True
False
