wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz - print + input

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is Python used for in programming?

a)

Graphic design

b)

Web development

c)

Scientific research

d)

All of the above

2.

Which of the following is an example of a variable in Python?

a)

"Hello"

b)

10

c)

x

d)

print()

3.

How do you assign a value to a variable in Python?

a)

variable = value

b)

value = variable

c)

assign(variable, value)

d)

None of the above

4.

What does the print() function do in Python?

a)

Perform mathematical operations

b)

Define variables

c)

Capture user input

d)

Display output

5.

Which of the following is a correct way to print the phrase "Hello, World!" in Python?

a)

print("Hello, World!")

b)

print(Hello, World!)

c)

display("Hello, World!")

d)

show "Hello, World!"

6.

How do you capture user input in Python?

a)

scan()

b)

get_input()

c)

input()

d)

user()

7.

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

a)

Integer

b)

String

c)

Float

d)

Boolean

8.

How can you convert user input to an integer in Python?

a)

int(input())

b)

input(int)

c)

convert(input())

d)

integer(input())

9.

What is the purpose of the + operator when used with strings in Python?

a)

Concatenation

b)

Subtraction

c)

Division

d)

Multiplication

10.

How do you print the output of a variable named age in Python?

a)

print("age")

b)

output(age)

c)

print(age)

d)

display(age)

11.

What does the # symbol indicate in Python?

a)

Addition

b)

Comment

c)

Trend

d)

Division

12.

What does the input() function return in Python?

a)

Boolean

b)

Integer

c)

Float

d)

String

13.

How do you prompt the user for their name and print a greeting in Python?

a)

print("Hello, " + input())

b)

name = input()

print("Hello, " + name)

c)

name = get_name()

print("Hello, " + name)

d)

greet(input("Hello, "))

14.

Which data type is used for decimal numbers in Python?

a)

float

b)

string

c)

boolean

d)

Integer

15.

What is the purpose of the str() function in Python?

a)

Convert to string

b)

convert to integer

c)

convert to float

d)

convert to boolean

16.

How do you use variables with the print() function to display dynamic messages?

a)

print("Variable")

b)

print(variable)

c)

print("Hello, " + variable)

d)

print("Hello, " variable)

17.

What is the purpose of comments in Python?

a)

Hide code

b)

Explain code

c)

Execute code

d)

Output message

18.

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

a)

16

b)

11

c)

26

d)

10

19.

What is the correct syntax to declare a variable name and assign the value "John" to it in Python?

a)

variable name = "John"

b)

name := "John"

c)

name = "John"

d)

John = name

20.

What is the result of the following code?

(a)  

21.

What is the correct way to declare a variable count and assign the value 5 to it in Python?

a)

count:=5

b)

int count = 5

c)

5 = count

d)

count = 5

22.

What is the expected output of the Python code?

a)

Hello, input!

b)

Hello, name!

c)

Depends on the users input

d)

Enter your name: Hello, !

23.

What will happen if the code is executed?

a)

It will print the user's age.

b)

It will cause an error.

c)

It will prompt the user to enter their age.

d)

It will print "Next year, you will be 1."

24.

What does the above code snippet do?

a)

Prints "Python is technology!"

b)

Prints "Python is awesome!"

c)

Prints "Python is awesome!technology"

d)

Causes an error

25.

What is the output of the code?

a)

The sum of the entered numbers

b)

An error will occur

c)

The product of the entered numbers

d)

The difference between the entered numbers