wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Test10

Total questions: 27

Worksheet time: 14mins

Name
Class
Date
1.

Which of the following is not a Python keyword?

a)

pass

b)

eval

c)

assert

d)

lambda

2.

What is the output of print(type(10)) in Python?

a)

<class 'int'>

b)

<class 'float'>

c)

<class 'number'>

d)

<class 'decimal'>

3.

What does the following code print: print(5 // 2)?

a)

2

b)

2.5

c)

3

d)

Error

4.

Which of the following is a correct statement about Python indentation?

a)

Indentation is optional.

b)

Indentation is used to define blocks of code.

c)

Indentation can be mixed (tabs and spaces).

d)

Python ignores indentation.

5.

Which of the following is not a valid Python variable name?

a)

my_var

b)

_myvar

c)

2myvar

d)

myvar2

6.

Which of the following operators in Python is used for exponentiation?

a)

^

b)

**

c)

*

d)

%

7.

Which symbol is used to start a comment in Python?

a)

//

b)

#

c)

/*

d)

;

8.

What is the output of print('Hello' + ' World') in Python?

a)

Hello

b)

HelloWorld

c)

Hello World

d)

Error

9.

Which of the following is a valid string in Python?

a)

"Hello'

b)

'Hello'

c)

Hello

d)

"Hello

10.

What does the 'is' operator check in Python?

a)

If two variables point to the same object in memory

b)

If two variables have the same value

c)

If a value is not null

d)

If a variable exists

11.

What is the result of 3 % 2 in Python?

a)
1
b)
3
c)
0
d)
2
12.

What type of literal is 5.5 in Python?

a)
boolean
b)
string
c)
float
d)
integer
13.

What is the output of the following: print(2 ** 3)?

a)
8
b)
6
c)
9
d)
4
14.

Which of the following can be used as a variable name in Python?

a)

for

b)

1_var

c)

_myvar

d)

if

15.

What is the data type of the variable x in the statement x = '5'

a)
integer
b)
float
c)
string
d)
boolean
16.

Which of the following is a membership operator in Python?

a)
in
b)

is

c)

==

d)
not in
17.

Which of the following statements is correct regarding Python?

a)

Python is case-insensitive.

b)

Python is case-sensitive.

c)

Python uses semicolons to end statements.

d)

Python is compiled, not interpreted.

18.

What will the following code print: print('10' + '5')?

a)

10 5

b)
105
c)
50
d)

10 50

19.

What is the return type of the input() function in Python?

a)
list
b)
float
c)
int
d)
str
20.

What will the following code print if the user enters 25

age = input("Enter your age: ")

print(type(age))

a)

<class 'int'>

b)

<class 'str'>

c)

<class 'float'>

d)

Error

21.

Which of the following is the correct syntax to get an integer input from a user?

a)

age = input(int("Enter your age: "))

b)

age = int(input("Enter your age: "))

c)

age = int("Enter your age: ")

d)

input = int("age")

22.

What happens if you call input() without any arguments?

a)

It raises an error.

b)

It waits for user input without any message.

c)

It provides a default prompt message.

d)

It returns None.

23.

What is bytecode in Python?

a)
Bytecode is a high-level programming language used in Python.
b)
Bytecode in Python is an intermediate representation of source code that the Python virtual machine executes.
c)
Bytecode is a type of Python library for data processing.
d)
Bytecode is the final executable code in Python.
24.

Where does Python store the compiled bytecode files?

a)

In the same directory as the source code, with a .pyc extension.

b)

In a temporary directory with a .byte extension.

c)

In the system's memory.

d)

It doesn't store bytecode files.

25.

What is the function of the Python Virtual Machine (PVM)?

a)

To interpret and execute the bytecode.

b)

To compile the Python source code.

c)

To generate bytecode.

d)

To handle memory management during code execution.

26.

What role does the Python garbage collector play in the code lifecycle?

a)

It compiles the code to bytecode.

b)

It manages memory allocation and deallocation during program execution.

c)

It converts the bytecode into machine code.

d)

It optimizes code during compilation.

27.

Which of the following statements is true about the print() function in Python?

a)

print() can only print string data types.

b)

print() can print any data type.

c)

print() only works with numeric data types.

d)

print() requires at least one argument.