Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python data types

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?

x = x + 2

a)

This would fail as it is a syntax error

b)

Produce the value "false" because "x" can never equal "x+2"

c)

Retrieve the current value for x, add two to it and put the sum back into x

d)

Create a function called "x" and put the value 2 in the function

2.

What will be the value of x after the following statement executes:

x = 1 + 2 * 3 - 8 / 4

a)

5.0

b)

4

c)

15

d)

3.0

3.

Which of the following elements of a mathematical expression in Python is evaluated first?

a)

*

b)

/

c)

()

d)

+

4.

Which of the following is not a Python reserved word?

a)

iterate

b)

continue

c)

break

d)

else

5.

Which of the following is a bad Python variable name?

a)

Spam

b)

_spam

c)

23spam

d)

SPAM23

6.

Which character represents a comment in Python code?

a)

*

b)

#

c)

&

d)

$

7.

What is the Python code needed to ask a user for input?

a)

input("what is your name?")

b)

input="what is your name?"

c)

(input)=what is your name?

d)

input=what is your name?

8.

Which is the operator used to FIND THE REMAINDER OF DIVIDING?

a)

+

b)

*

c)

/

d)

%

9.

Which is the operator used to MULTIPLY?

a)

+

b)

*

c)

/

d)

-

e)

%

10.

Which of the following data types can consist of numbers, alphabets and symbols?

a)

String

b)

Integer

c)

Float

d)

Boolean

11.

What will be the output from the following Python code?

print("3+4")

a)

7

b)

3+4

c)

34

d)

SyntaxError

12.

What will the output be from the following Python code?

print(3+4)

a)

3+4

b)

7

c)

SyntaxError

d)

print(3+4)

13.

What is the output of the following Python code?

print('Hello' + "world!")

a)

Helloworld!

b)

Hello world!

c)

'Hello' "world!"

d)

Error message

14.

What is an Integer?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

15.

What is a String?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.