WorksheetsPython Beginners Week 6
Total questions: 13
Worksheet time: 6mins
Select all the typecasting functions.
type()
str()
int()
float()
input()
If the user enters the number 12, what is displayed by the print() function?
num
Enter number: 12
12
12.0
twelve
If a user inputs the number 100 into num1 and 200 into num2, what does the print() statement display?
300
100200
100 200
num1+num2
Type error
How do you typecast this variable into an integer: six = "6"
It's already an integer
type(6)
int(6)
int(six)
int(str(six))
How do you typecast this variable into a float: seven = 7.0
It's already a float
float(7.0)
flt(seven)
flt(7.0)
How do you typecast this variable into an integer: greeting = "HI"
It's already an integer
int(greeting)
int("HI")
int(HI)
Error
If a user inputs 14 into the variable num1 and 10 into the variable num2, what does the print() statement display?
num1+num2
10+14
24
1014
Error
(Look closely) If a user inputs the number 10 into num1 and the number 20 into num2, what does this program print out?
num1+num2
10+20
30
10 20
Error
(Look closely) What is wrong with this code?
On line 10, the numbers are added incorrectly
On line 10, the result is incorrectly typecasted into a string
On line 13, the numbers are added incorrectly
There is nothing wrong with it
What is a conditional statement?
A sentence with 'if','but','or','which' or 'and'
A line of code that asks users a question
An ‘if’ statement containing a CONDITION and INSTRUCTION.
A statement in programming
What is the correct order?
IF, ELIF, ELSE
ELSE, IF, ELIF
IF, ELSE, ELIF
ELIF, IF, ELSE
ELIF, ELSE, IF
What will this print out: print(1==1)
True
False
Error
1
2
Favourite season?
Summer
Spring
Winter
Autumn
Salt & Pepper
