wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 20

Worksheet time: 3600secs

Name
Class
Date
1.

What is the correct way to print "Hello, World!" in Python?

a)

echo("Hello, World!")

b)

printf("Hello, World!")

c)

print("Hello, World!")

d)

console.log("Hello, World!")

2.

Which symbol is used for comments in Python?

a)

//

b)

#

c)
d)

/** */

3.

What data type is the value 42 in Python?

a)

String

b)

Integer

c)

Float

d)

Boolean

4.

What will this code output? x = 5 y = 3 print(x + y)

4 lines
5.

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

a)

2ndNumber

b)

first_name

c)

my-name

d)

class

6.

What is the output of this code? print(type(3.14))

4 lines
7.

What keyword is used to define a function in Python?

4 lines
8.

Write a Python statement to assign the value 10 to a variable called score.

4 lines
9.

What is the correct way to create a list of numbers from 1 to 5?

4 lines
10.

What will be the output of this code? for i in range(3): print(i)

4 lines
11.

How do you start a while loop in Python? Write the syntax for a while loop that runs while count is less than 5.

4 lines
12.

What is the output of this code? print("Python"[1])

4 lines
13.

What does len() function do in Python?

4 lines
14.

How would you add the number 7 to the end of the list numbers = [1, 2, 3]?

4 lines
15.

What will the following code print? x = 10 if x > 5: print("Greater") else: print("Smaller or equal")

4 lines
16.

Which of these is a Python tuple?

a)

[1, 2, 3]

b)

(1, 2, 3)

c)

{1, 2, 3}

d)
17.

What is the output of this code? x = "5" y = 2 print(x * y)

4 lines
18.

How do you import the math module in Python?

4 lines
19.

Write a function named greet that takes a name as a parameter and prints "Hello, name!"

4 lines
20.

What is the difference between == and = in Python?

4 lines