wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

python

Total questions: 19

Worksheet time: 14mins

Name
Class
Date
1.

Which of the following is NOT a built-in data type in Python?

a)

list

b)

dict

c)

tuple

d)

tree

2.

What does type casting mean in Python?

a)

Converting a list into a dictionary

b)

Assigning a type to a function

c)

Converting a variable from one data type to another

d)

Declaring variables with type annotations

3.

What will print("Python"[1:4]) display?

a)

yth

b)

ytho

c)

Pyt

d)

ython

4.

What is the Boolean value of the expression 5 > 3 and 2 < 1?

a)

True

b)

False

c)

1

d)

None

5.

What will print(10 // 3) gives output?

a)

3.33

b)

3

c)

3.0

d)

4

6.

What is the error in the above code snippet?

a)

Indentation Error

b)

Syntax Error

c)

Name Error

d)

Type Error

7.

Which of the following methods can be used to remove an element from a list in Python?

a)

list.remove()

b)

list.delete()

c)

list.pop()

d)

Both A and C

8.

What does the append() method do to a list?

a)

Adds an element to the beginning of the list

b)

Adds an element to the end of the list

c)

Removes an element from the list

d)

Sorts the list in ascending order

9.

Which of the following statements is used to return the data type of a variable in Python?

a)

type(variable)

b)

get_type(variable)

c)

type_of(variable)

d)

variable.type()

10.

What is the output of the following expression?

3 * "hello"

a)

hellohellohello

b)

3hello

c)

hello3

d)

None

11.

Which of these is a valid variable name in Python?

a)

1variable

b)

my-variable

c)

my_variable

d)

my variable

12.

Which of the following is a comparison operator in Python?

a)

+=

b)

==

c)

and

d)

=

13.

What is the result of this expression:

"Python"[::-1]

a)

Python

b)

nohtyP

c)

nothyP

d)

Error

14.

Which of the following will remove whitespace from both ends of a string?

a)

strip()

b)

trim()

c)

rstrip()

d)

clean()

15.

What will "hello".capitalize() return?

a)

Hello

b)

HELLO

c)

hello

d)

Error

16.

What is the result of "abc" + 123?

a)

abc123

b)

abc 123

c)

abc+123

d)

Error

17.

How do you feel when you wake up early for the internship?

a)

"Excited for the new opportunities!"

b)

"I’m totally ready to conquer the day!"

c)

"I’ll just take this one coffee at a time."

d)

"Me, questioning my life choices while my bed looks way too comfortable."

18.

What is the result of: not (True and False)?

a)

True

b)

False

c)

None

d)

Error

19.

What is the value of 5 + 3 * 2 in Python?

a)

16

b)

11

c)

13

d)

10