wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Variables

Total questions: 16

Worksheet time: 9mins

Name
Class
Date
1.

print ("7" * 4)

a)

7777

b)

28

c)

error

2.

print("4*6")

a)

46

b)

24

c)

4*6

d)

error

3.

print(3*8)

a)

38

b)

24

c)

3*8

d)

error

4.

print ("the cost is £"+ str(2*5))

a)

the cost is £10

b)

the cost is £ 7

c)

the cost is £ 10

d)

the cost is £ 2*5

5.

print("Mr."+"John")

a)

error

b)

Mr. John

c)

Mr.John

6.

print("the value is"+ 5)

a)

the value is5

b)

error

c)

the value is 5

7.

.......... this function converts a variable to string.

a)

int()

b)

float()

c)

bool()

d)

str()

8.

.......... this function converts a variable to integer.

a)

int()

b)

float()

c)

bool()

d)

str()

9.

.......... this function converts a variable to float.

a)

int()

b)

float()

c)

bool()

d)

str()

10.

A programmer would like to set a distance value to a variable. What variable type should he use?

a)

string

b)

integer

c)

float

d)

boolean

11.

A programmer would like to set cost of a product to a variable. What variable type should he use?

a)

string

b)

integer

c)

float

d)

boolean

12.

A programmer would like to set a quantity of crisps bags to a variable. What variable type should he use?

a)

String

b)

Integer

c)

Float

d)

Boolean

13.

.............. calculates and prints the average of two numbers

a)

print((num1+num2)/2)

b)

print(num1+num2/2)

c)

print(num1+num2)

14.

num=5

num=str(num)

on line 1, the type of Num variable was integer but on the second line it was converted to ......

a)

boolean

b)

string

c)

float

15.

You can multiply a string by a number. The string will be printed multiple times equal to that number e.g. print ("Hi"*3) will output HiHiHi

a)

False

b)

True

16.

Multiplying two strings will generate error

a)

Ture

b)

False