Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Beginners Week 6

Total questions: 13

Worksheet time: 6mins

Name
Class
Date
1.

Select all the typecasting functions.

a)

type()

b)

str()

c)

int()

d)

float()

e)

input()

2.

If the user enters the number 12, what is displayed by the print() function?

a)

num

b)

Enter number: 12

c)

12

d)

12.0

e)

twelve

3.

If a user inputs the number 100 into num1 and 200 into num2, what does the print() statement display?

a)

300

b)

100200

c)

100 200

d)

num1+num2

e)

Type error

4.

How do you typecast this variable into an integer: six = "6"

a)

It's already an integer

b)

type(6)

c)

int(6)

d)

int(six)

e)

int(str(six))

5.

How do you typecast this variable into a float: seven = 7.0

a)

It's already a float

b)

float(7.0)

c)

flt(seven)

d)

flt(7.0)

6.

How do you typecast this variable into an integer: greeting = "HI"

a)

It's already an integer

b)

int(greeting)

c)

int("HI")

d)

int(HI)

e)

Error

7.

If a user inputs 14 into the variable num1 and 10 into the variable num2, what does the print() statement display?

a)

num1+num2

b)

10+14

c)

24

d)

1014

e)

Error

8.

(Look closely) If a user inputs the number 10 into num1 and the number 20 into num2, what does this program print out?

a)

num1+num2

b)

10+20

c)

30

d)

10 20

e)

Error

9.

(Look closely) What is wrong with this code?

a)

On line 10, the numbers are added incorrectly

b)

On line 10, the result is incorrectly typecasted into a string

c)

On line 13, the numbers are added incorrectly

d)

There is nothing wrong with it

10.

What is a conditional statement?

a)

A sentence with 'if','but','or','which' or 'and'

b)

A line of code that asks users a question

c)

An ‘if’ statement containing a CONDITION and INSTRUCTION.

d)

A statement in programming

11.

What is the correct order?

a)

IF, ELIF, ELSE

b)

ELSE, IF, ELIF

c)

IF, ELSE, ELIF

d)

ELIF, IF, ELSE

e)

ELIF, ELSE, IF

12.

What will this print out: print(1==1)

a)

True

b)

False

c)

Error

d)

1

e)

2

13.

Favourite season?

a)

Summer

b)

Spring

c)

Winter

d)

Autumn

e)

Salt & Pepper