wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Introduction to Python Quiz

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Who developed Python programming language?

a)

Dennis Ritchie

b)

Guido van Rossum

c)

James Gosling

d)

Bjarne Stroustrup

2.

In which year was Python first released?

a)

1989

b)

1991

c)

1995

d)

2000

3.

Which of the following is a key feature of Python?

a)

Compiled language

b)

Low-level language

c)

Object-oriented

d)

Static typing

4.

Which of the following makes Python easy to learn?

a)

Complex syntax

b)

Simple and readable code

c)

Requires extensive memory management

d)

Requires pre-compilation

5.

Python is an example of which type of programming language?

a)

High-level

b)

Assembly-level

c)

Machine-level

d)

Low-level

6.

Python is a:

a)

Compiled language

b)

Interpreted language

c)

Both compiled and interpreted

d)

None of the above

7.

What type of programming paradigms does Python support?

a)

Procedural

b)

Object-oriented

c)

Functional

d)

All of the above

8.

Which file extension is used for Python files?

a)

.java

b)

.py

c)

.cpp

d)

.pyt

9.

What is the default Python IDE that comes with Python installation?

a)

PyCharm

b)

Jupyter Notebook

c)

IDLE

d)

Eclipse

10.

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

a)

5

b)

6

c)

8

d)

9

11.

Which of the following tools is used to create virtual environments in Python?

a)

Anaconda

b)

pip

c)

venv

d)

Jupyter

12.

What is the purpose of Anaconda?

a)

Machine learning only

b)

Data science and machine learning

c)

Web development

d)

Game development

13.

Which command is used to install Jupyter Notebook using pip?

a)

install jupyter

b)

pip install jupyter

c)

jupyter install

d)

python install jupyter

14.

What is the default package manager for Python?

a)

npm

b)

pip

c)

conda

d)

brew

15.

How do you activate a virtual environment in Python (Windows)?

a)

activate

b)

env

c)

source env/bin/activate

d)

. activate

16.

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

a)

1var

b)

_var

c)

@var

d)

var-1

17.

Which of the following is not a Python data type?

a)

int

b)

float

c)

char

d)

list

18.

How do you declare a comment in Python?

a)

//

b)

c)

#

d)

/* */

19.

Which operator is used for floor division in Python?

a)

/

b)

//

c)

%

d)

**

20.

What will type(3.14) return?

a)

int

b)

float

c)

double

d)

decimal

21.

Which keyword is used to start an if statement?

a)

if

b)

when

c)

for

d)

else

22.

What will the following code output? if 5 > 3: print("True") else: print("False")

a)

True

b)

False

c)

Error

d)

None

23.

What is the correct way to write an if-else statement in one line?

a)

if x > y print("Yes") else print("No")

b)

print("Yes") if x > y else print("No")

c)

print("Yes" if x > y else "No")

d)

Both B and C

24.

How many times will the following loop execute? for i in range(5): print(i)

a)

4

b)

5

c)

6

d)

Infinite

25.

Which of the following is true about the while loop?

a)

Executes until the condition becomes true

b)

Executes until the condition becomes false

c)

Executes a fixed number of times

d)

Executes at least once

26.

What will the following code output? x = 10 while x > 5: print(x) x -= 2

a)

10, 8, 6

b)

10, 8, 6, 4

c)

Infinite loop

d)

None

27.

What keyword is used to exit a loop early?

a)

skip

b)

continue

c)

break

d)

exit

28.

Which statement is used to skip the current iteration and move to the next one?

a)

continue

b)

pass

c)

break

d)

skip

29.

What is the purpose of the else block in a loop?

a)

Executes only if the loop condition is false

b)

Executes if the loop runs completely without a break

c)

Executes at the beginning of the loop

d)

None of the above

30.

What is the output of bool([])?

a)

True

b)

False

c)

None

d)

Error

31.

Which function is used to get user input in Python 3?

a)

get()

b)

input()

c)

scan()

d)

read()

32.

What is the output of print(type("5"))?

a)

int

b)

float

c)

str

d)

None

33.

What will happen if you try to use a reserved keyword as a variable name?

a)

The code will work fine

b)

It will raise a syntax error

c)

It will be ignored

d)

It will convert the keyword to a string

34.

How do you convert a string "123" to an integer in Python?

a)

int("123")

b)

string("123")

c)

str("123")

d)

float("123")

35.

What is the correct syntax to define a multi-line string in Python?

a)

"This is a multiline string"

b)

"""This is a multiline string"""

c)

'This is a multiline string'

d)

[[This is a multiline string]]

36.

Which operator is used to concatenate two strings in Python?

a)

+

b)

*

c)

&

d)

&&

37.

What will be the output of print("Python"[::-1])?

a)

Python

b)

Pyt

c)

nohtyP

d)

Error

38.

What is the output of print(bool(""))?

a)

True

b)

False

c)

None

d)

Error

39.

What will the following code output? print(2 == 2.0)

a)

True

b)

False

c)

TypeError

d)

None

40.

What will print(2 / 0) output?

a)

0

b)

Infinity

c)

Error

d)

None

41.

Which of the following is the correct format for a for-loop in Python?

a)

for x in 5:

b)

for x in range(5):

c)

for x <= 5:

d)

for x to 5:

42.

What will the following code output? for i in range(2, 7, 2): print(i)

a)

2, 3, 4, 5, 6

b)

2, 4, 6

c)

2, 3, 5

d)

2, 5, 6

43.

What is the output of the following code? x = 3 while x > 0: x -= 1 print(x)

a)

3, 2, 1

b)

2, 1, 0

c)

1, 0

d)

2, 1

44.

What is the output of the following code? x = 5 if x > 3: pass else: print("Hello")

a)

Hello

b)

No output

c)

Error

d)

None

45.

What is the output of the following code? for i in range(3): if i == 2: break print(i)

a)

0, 1, 2

b)

0, 1

c)

1, 2

d)

0

46.

What is the output of the following code? for i in range(5): if i == 2: continue print(i)

a)

0, 1, 3, 4

b)

0, 1, 2, 3, 4

c)

1, 3, 4

d)

1, 2, 3, 4

47.

What happens if you use else with a for loop?

a)

Executes when the loop is finished without a break

b)

Executes when the loop ends with a break

c)

Executes only when the loop condition is true

d)

Causes an error

48.

What will the following code output? if not 0: print("True") else: print("False")

a)

True

b)

False

c)

None

d)

Error

49.

Which of the following is not a valid comparison operator in Python?

a)

==

b)

!==

c)

<=

d)

>

50.

Which of the following is used to check the identity of two objects in Python?

a)

=

b)

==

c)

is

d)

in