wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Basic Variables, Arithmetic and Display

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

In Python, which of these assigns an integer to x?

a)

int x = 5

b)

x = 5

c)

x := 5

d)

x == 5

2.

Which data type would the value "Hello" be?

a)

int

b)

string

c)

boolean

d)

float

3.

In Python, what is the result of 3+7?

a)

10

b)

37

c)

"3 + 7"

d)

4

4.

In Python, what is the result of "3"+"7"?

a)

10

b)

37

c)

"3 + 7"

d)

4

5.

In Python, which of these displays what is stored in a variable called `name`?

a)

print name

b)

print(name)

c)

echo(name)

d)

printf(name)

6.

In Python, which of these is a boolean value?

a)

"True"

b)

1

c)

True

d)

"False"

e)

false

7.

What is the result of 8-3 in Python?

a)

5

b)

83

c)

-5

d)

3

e)

38

8.

Which of the following is NOT a basic data type in Python?

a)

int

b)

string

c)

boolean

d)

list

9.

What will print(2 * 4) output?

a)

8

b)

24

c)

6

d)

2 * 4

e)

Nothing

10.

Which of these is a valid assignment in Python?

a)

language = "Python"

b)

language == "Python"

c)

language := "Python"

d)

string language = "Python"

11.

What is the result of 10/2 in Python?

a)

5

b)

October 2nd

c)

2

d)

0.2

e)

10

12.

x = 7
y = 3
What is displayed by print(x + y)?

a)

10

b)

21

c)

4

d)

73

e)

37

13.

name = "Alice"
Which of these will print "Hello, Alice"?

a)

print("Hello, name")

b)

print("Hello, ", name)

c)

print(Hello, name)

d)

print(name, "Hello,")

14.

a = 5

b = 2

What is the result of a * b?

a)

10

b)

7

c)

3

d)

25

e)

52

15.

What is displayed by this Python code?

is_student = True
print(is_student)

a)

"True"

b)

True

c)

1

d)

Yes

e)

is_student

16.

x = 10

Which statement prints "The value is 10"?

a)

print("The value is", x)

b)

print("The value is" + x)

c)

print("The value is x")

d)

print(x, "The value is")

e)

print(x)

17.

If x = 4, what is the result of x * x?

a)

8

b)

16

c)

4

d)

2

18.

flag = False

Which statement will display the value of flag?

a)

print(flag)

b)

print("flag")

c)

print(False)

d)

print(flag == False)

19.

What data type is stored in the variable x?
x = False

a)

int

b)

string

c)

boolean

20.

What data type is stored in the variable x?
x = "Today"

a)

int

b)

string

c)

boolean