WorksheetsPython Quiz Questions
Total questions: 10
Worksheet time: 5mins
What is the output of the following code? print(2 * 3 ** 2)
36
18
12
9
Which of the following is not a valid variable name in Python?
_myvar
2var
my_var
var2
What will be the output of the following code? print(bool([]), bool(0), bool(None))
False False False
True True True
False True False
True False True
How do you open a file for both reading and writing in Python?
"r"
"w"
"rw"
"r+"
What will len("Python") return?
5
6
7
Error
What is the correct way to define a function in Python?
define my_function():
def my_function():
function my_function():
func my_function():
What will list(range(2, 10, 2)) return?
[2, 3, 4, 5, 6, 7, 8, 9]
[2, 4, 6, 8]
[2, 4, 6, 8, 10]
[2, 6, 10]
Which keyword is used to create a class in Python?
class
def
object
struct
What is the output of the following code? print("Python".lower())
PYTHON
python
Python
error
What is the result of 10 // 3 in Python?
3.33
3.0
3
4
