Quiz: Variables, Data Types, Strings and Booleans

Test your Python knowledge with this quiz on variables, data types, strings, and Booleans.

1.

Which of the following correctly defines a variable in Python?

2.

What will be the output of the following code?

python
1
2
3
x = 5
x = "Hello"
print(x)
3.

What will be the output of this code?

python
1
2
3
fruits = ["Apple", "Banana", "Cherry"]
x, y, z = fruits
print(y)
4.

Which of the following is a legal Python variable name?

5.

What is the result of this string slicing?

python
1
2
text = "Hello, World!"
print(text[2:5])
6.

What will this code print?

python
1
2
print(bool("Hello"))
print(bool(0))