wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Exploring Python Basics Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the data type of the value `42` in Python?

a)

String

b)

Integer

c)

Float

d)

Boolean

2.

Which of the following is a valid Python list?

a)

`[1, 2, 3]`

b)

`(1, 2, 3)`

c)

`{1, 2, 3}`

d)

`1, 2, 3`

3.

What will be the output of the following code? ```python if 5 > 3: print("Hello") ```

a)

Nothing

b)

Error

c)

Hello

d)

5 > 3

4.

Which of the following is a mutable data type in Python?

a)

Tuple

b)

String

c)

List

d)

Integer

5.

What is the index of the first element in a Python list?

a)

0

b)

1

c)

-1

d)

2

6.

What will be the output of the following code? ```python my_list = [10, 20, 30, 40] print(my_list[2]) ```

a)

10

b)

20

c)

30

d)

40

7.

Which of the following is not a Python data type?

a)

Integer

b)

Float

c)

Character

d)

Boolean

8.

What is the result of the expression `3.0 + 4` in Python?

a)

7

b)

7.0

c)

3.4

d)

Error

9.

What will be the output of the following code? ```python if 2 == 2: print("Yes") else: print("No") ```

a)

Yes

b)

No

c)

Error

d)

2 == 2

10.

Which of the following is a correct way to declare a list in Python?

a)

`list = [1, 2, 3]`

b)

`list = (1, 2, 3)`

c)

`list = {1, 2, 3}`

d)

`list = 1, 2, 3`

11.

What will be the output of the following code? ```python my_list = [1, 2, 3, 4] my_list.append(5) print(my_list) ```

a)

`[1, 2, 3, 4]`

b)

`[1, 2, 3, 4, 5]`

c)

`[5, 1, 2, 3, 4]`

d)

`[1, 2, 3, 5, 4]`

12.

Which of the following is a correct if statement in Python?

a)

`if x = 5:`

b)

`if x == 5:`

c)

`if (x == 5)`

d)

`if x := 5`

13.

Which of the following is a valid way to access the last element of a list `my_list`?

a)

`my_list[-1]`

b)

`my_list[0]`

c)

`my_list[1]`

d)

`my_list[len(my_list)]`

14.

What will be the output of the following code? ```python if 10 < 5: print("Smaller") else: print("Greater") ```

a)

Smaller

b)

Greater

c)

Error

d)

10 < 5

15.

What is the data type of the value `True` in Python?

a)

String

b)

Integer

c)

Float

d)

Boolean

16.

What is the data type of the value "True" in Python?

a)

int

b)

str

c)

bool

d)

float

17.

Which of the following is a data type in Python?

a)

integer

b)

number

c)

digit

d)

numeral

18.

What is the data type of the following variable? ```python x = 3.14 ```

a)

`int`

b)

`str`

c)

`float`

d)

`bool`

19.

What is a variable in Python?

a)

A type of Python snake

b)

A reserved word that cannot be used for anything other than its pre-defined purpose

c)

A name that is used to denote something or a value is called a variable

d)

A tool used to control the flow of a program

20.

age = '5'


In the code above, age is a

a)

string

b)

integer

c)

floating point