Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Codeforlife python worksheet 2 - Variables, Input and Casting

Total questions: 26

Worksheet time: 19mins

Name
Class
Date
1.

What is the technical name we give to an area of memory which we can store something in using a label? HINT: Var (a)  

2.

When we run an input() function in python, what sort of data type does it always return?

a)

string

b)

integer

c)

real

d)

boolean

3.

What is the technical word for converting one data type into another in Python? HINT: Cas (a)  

4.

If we wanted to convert "3" into an integer, what do we need to replace the blank with

___("3")

a)

int

b)

float

c)

bool

d)

str

5.

What is this style of writing variables called? my_height = 6

a)

snake case

b)

slug case

c)

snail case

d)

camel case

6.

What's wrong with this code?

print("Hello", name)

name = input("Enter your name: ")

a)

There is a missing bracket

b)

Name should be converted to an integer

c)

The lines are the wrong way around

d)

Input has been spelled incorrectly

7.

What's wrong with this code?

COUNTRY = input("Enter a country name:")

print("I'd like to go to", country)

a)

Missing quotation marks

b)

Missing a bracket

c)

COUNTRY should be converted to an integer

d)

COUNTRY and country are different variables

8.

How do we get a decimal value from the user in python?

a)

x = float(input())

b)

x = int(input())

c)

x = str(input())

d)

x = bool(input())

9.

What is the name given to the data type which stores decimals in python?

(a)  

10.

Which data type is used to store text? HINT: Str (a)  

11.

Which data type is used to store whole numbers? HINT: Int (a)  

12.

If we wanted to change the string "3" into a decimal number, which one would you choose to cast the value?

a)

int("3")

b)

float("3")

c)

bool("3")

d)

str("3")

13.

What is the name of the data type we use to store TRUE OR FALSE in python? HINT: B (a)  

14.

Which word can describe joining strings together e.g. "fire" + "work" (HINT: Concat (a)   )

15.

What will this output?

print(10 + 15)

a)

25

b)

1015

c)

10 + 15

d)

Error due to trying to add a string to an integer

16.

What will this output?

print("10" + "15")

a)

1015

b)

25

c)


10 + 15

d)

Error due to trying to add a string to an integer

17.

What will this output?

print("10" + 15)

a)


1015

b)

Error due to trying to add a string to an integer

c)

25

d)

10 + 15

18.

What will this output?

print("10 + 15")

a)

1015

b)

25

c)

Error due to trying to add a string to an integer

d)

10 + 15

19.

Fill in the blank. + - / * % are all types of __________ operators (HINT: Ari_______)

(a)  

20.

What is the name we use for "10 + 15" in this line of python print("10 + 15")

a)


string literal

b)


string actually

c)

string exact

d)


string precise

21.

Which symbol (character) do we use to FIND THE REMAINDER OF two numbers divided by eachother in python?

(a)  

22.

Which two symbols (characters) do we use to FIND THE WHOLE NUMBER DIVISION of two numbers in python? (HINT: Also called 'Integer division' or 'Quotient')

(a)  

23.

Which two symbols (characters) do we use to RAISE ONE NUMBER TO THE POWER OF ANOTHER in python?

(a)  

24.

Which data type is "hello" ?

a)

string

b)

real

c)

integer

d)

boolean

25.

Which data type is used to store either True or False? HINT: Boo (a)  

26.

Which data type is the number 3.14 ? HINT: 3.14 is a decimal number

a)

integer

b)

real

c)

boolean

d)

string