wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python: Print Function, Data Types, and Variables

Total questions: 20

Worksheet time: 27mins

Name
Class
Date
1.

What is the correct way to declare a string variable in Python?

a)

string name = "Hello"

b)

str name = "Hello"

c)

name = "Hello"

d)

name = Hello

2.

Which of the following is an integer in Python?

a)

3.14

b)

"42"

c)

42

d)

True

3.

How do you correctly print the text "Hello, World!" in Python?

(a)  

4.

Which of the following is a floating point number?

a)

7

b)

7.0

c)

"7.0"

d)

True

5.

What is the boolean value of the expression 5 > 3 in Python?

(a)  

Choose from the below words
True
False
5
3
6.

Which of the following is a correctly named variable in Python?

a)

1st_variable

b)

firstVariable

c)

first-variable

d)

first variable

7.

What will be the output of the following code: print(3 + 4.5)?

(a)  

8.

What is the result of the expression 10 // 3 in Python?

(a)  

9.

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

a)

my_variable

b)

myVariable

c)

my-variable

d)

_myVariable

10.

What will be the output of the following code: print("5" + "3")?

(a)  

11.

What is the result of the expression 4 * 2.5 in Python?

(a)  

12.

Which of the following statements will print the boolean value False?

a)

print(5 > 10)

b)

print(10 > 5)

c)

print(5 == 5)

d)

print("False")

13.

What is the correct way to declare a variable with a floating point number in Python?

a)

float number = 3.14

b)

number = 3.14

c)

number = "3.14"

d)

float number = "3.14"

14.

How do you create a variable named bestNumber with the numeric value 5 in Python?

(a)  

15.

How are variables declared in Python?

4 lines
16.

Two students are given the following line of code:

print(7 + 8 + "I love pizza")

Student 1 says that the computer will print 7 8 I love pizza to the console.

Student 2 says that the computer will print an Error message.

Which student is correct and why?

4 lines
17.

Tom is coding a application using the Python coding language. He wants the computer to print "My name is Tom and I am 24 years old!" to the console using the following code:

user_name = Tom

age = 24

print("My name is, Tom, "and I am", 24, "years old!")

What is wrong with Tom's code and how can he fix it making sure he uses variables?

4 lines
18.

Type the code that would tell people your favorite movie. Make sure that if the code was ran that your name and the name of your favorite movie would be included. Also make sure that your code includes 2 different variables.

4 lines
19.

Type the Python code that would print your first and last name to the console.

4 lines
20.

Type the Python code that has an equation that would print the integer 1 to the console and that uses 3 different operators.

4 lines