WorksheetsCodeforlife python worksheet 2 - Variables, Input and Casting
Total questions: 26
Worksheet time: 19mins
What is the technical name we give to an area of memory which we can store something in using a label? HINT: Var (a)
When we run an input() function in python, what sort of data type does it always return?
string
integer
real
boolean
What is the technical word for converting one data type into another in Python? HINT: Cas (a)
If we wanted to convert "3" into an integer, what do we need to replace the blank with
___("3")
int
float
bool
str
What is this style of writing variables called? my_height = 6
snake case
slug case
snail case
camel case
What's wrong with this code?
print("Hello", name)
name = input("Enter your name: ")
There is a missing bracket
Name should be converted to an integer
The lines are the wrong way around
Input has been spelled incorrectly
What's wrong with this code?
COUNTRY = input("Enter a country name:")
print("I'd like to go to", country)
Missing quotation marks
Missing a bracket
COUNTRY should be converted to an integer
COUNTRY and country are different variables
How do we get a decimal value from the user in python?
x = float(input())
x = int(input())
x = str(input())
x = bool(input())
What is the name given to the data type which stores decimals in python?
(a)
Which data type is used to store text? HINT: Str (a)
Which data type is used to store whole numbers? HINT: Int (a)
If we wanted to change the string "3" into a decimal number, which one would you choose to cast the value?
int("3")
float("3")
bool("3")
str("3")
What is the name of the data type we use to store TRUE OR FALSE in python? HINT: B (a)
Which word can describe joining strings together e.g. "fire" + "work" (HINT: Concat (a) )
What will this output?
print(10 + 15)
25
1015
10 + 15
Error due to trying to add a string to an integer
What will this output?
print("10" + "15")
1015
25
10 + 15
Error due to trying to add a string to an integer
What will this output?
print("10" + 15)
1015
Error due to trying to add a string to an integer
25
10 + 15
What will this output?
print("10 + 15")
1015
25
Error due to trying to add a string to an integer
10 + 15
Fill in the blank. + - / * % are all types of __________ operators (HINT: Ari_______)
(a)
What is the name we use for "10 + 15" in this line of python print("10 + 15")
string literal
string actually
string exact
string precise
Which symbol (character) do we use to FIND THE REMAINDER OF two numbers divided by eachother in python?
(a)
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)
Which two symbols (characters) do we use to RAISE ONE NUMBER TO THE POWER OF ANOTHER in python?
(a)
Which data type is "hello" ?
string
real
integer
boolean
Which data type is used to store either True or False? HINT: Boo (a)
Which data type is the number 3.14 ? HINT: 3.14 is a decimal number
integer
real
boolean
string
