wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Who created Python?

a)

James Gosling

b)

Dennis Ritchie

c)

Bjarne Stroustrup

d)

Guido van Rossum

2.

What is the latest version of Python mentioned?

a)

v3.11

b)

v3.10

c)

v3.12

d)

v3.13

3.

What is the purpose of a variable in Python?

a)

To store data

b)

To create functions

c)

To print output

d)

To manage memory

4.

What is the main use of the 'if' statement?

a)

To define functions

b)

To make decisions

c)

To create loops

d)

To store data

5.

What is the purpose of the 'input' function?

a)

To define functions

b)

To create variables

c)

To capture user data

d)

To display output

6.

Which version of Python is not backward-compatible?

a)

Python 0.9.0

b)

Python 1.0

c)

Python 3.0

d)

Python 2.7

7.

Which of the following is a Python library for AI/ML?

a)

Flask

b)

Pygame

c)

TensorFlow

d)

Tkinter

8.

What is the purpose of the 'for' loop?

a)

To iterate over a sequence

b)

To make decisions

c)

To create functions

d)

To store data

9.

What is the main benefit of Python's extensive standard library?

a)

It makes Python slower

b)

It complicates coding

c)

It provides many built-in functions

d)

It is only for advanced users

10.

What is the first step to start coding in Python?

a)

Download Python

b)

Write your first code

c)

Create a variable

d)

Install a game

11.

What is the output of the following Python program?

for i in range(5):

print(i+1, end ='')

a)

01234

b)

00000

c)

12345

d)

5

12.

What is a string in Python?

a)

A letter, number, word, or sentence in quotation marks

b)

A mathematical operation

c)

A conditional statement

d)

A data type

13.

What does the 'print' function do in Python?

a)

It calculates mathematical expressions

b)

It retrieves user input

c)

It displays text or numbers on the screen

d)

It stores data in a variable

14.

What type of value does the variable "user" hold in the example provided?

a)

A list

b)

A string

c)

A boolean

d)

An integer

15.

What are conditional statements in Python and give an example.

a)

Conditional statements in Python are used to execute the same code block regardless of the condition

b)

An example of a conditional statement in Python is 'for' loop

c)

Conditional statements in Python are used to execute different code blocks based on certain conditions. One common conditional statement is the 'if' statement, which executes a block of code only if a specified condition is true. For example: if x > 5: print('x is greater than 5')

d)

A conditional statement in Python is 'while', which executes a block of code only once

16.

Which of these codes is the correct syntax?

a)

Print ("Hello World")

b)

print ("Hello World")

c)

PRINT ("Hello World")

d)

print "Hello World"

17.

How do you declare a variable in Python, as shown in the video?

a)

var x = 5

b)

x = 5

c)

int x = 5

d)

x := 5

18.

What does Python use instead of curly braces {} for code blocks?

a)

Semicolons

b)

Parentheses

c)

Indentation

d)

Brackets

19.

What keyword defines a function in Python?

a)

func

b)

def

c)

function

d)

define

20.

What does the if statement do?

a)

Tests a condition and executes code based on the result

b)

Defines a function

c)

Creates a loop

d)

Declares a variable