Font size
WorksheetsVariables- Conditional-Looping reviews
Total questions: 18
Worksheet time: 28mins
What do we use variables for?
To store data
Print data
Produce functions
To get the users input what function do we use?
input
input<>
input()
INPUT()
What will be printed to the screen?
5 + John
Syntax error - you cannot add str and int together
John
JohnJohnJohnJohnJohn
Num = 90
Num = 20
print(Num)
90
4.5
20
1800
In the following code, what is happening?
foo = "bar"
A variable named foo is being created, with a value of "bar"
A variable named bar is being created, with a value of "foo"
In the following code, what type of variable is being created?
foo = "bar"
Integer
Float
String
The ‘else’ statement is optional in Python
TRUE
FALSE
The code inside ‘If’ statement is executed only once
FALSE
TRUE
What is the output?
more than 7
more than 23
spam
7
The program above prints
Numbers between 1 and 100 that are multiples of 5
Numbers between 1 and 100
Numbers between 1 and 100 divisible by 5
Numbers between 1 and 101 that are multiples of 5
The program above prints the sum of
all odd numbers less than 100
all even numbers less than 100
all numbers less than 100
4
3
2
1
3
2
1
0
8
6
4
2
Password
You want a password to protect your program, if the user enters the wrong password, the program will let them know. The program answer will be either “correct password” or “incorrect password”
Ps: use input function here
Rock / paper / scissors
Suppose Jack and Jill are playing rock paper scissors game.
The jack and Jill variables will have a choice of “rock” , “ scissors” or paper.
The input function have to be clear.
If Jack is a winner, print “ Jack wins”
If Jill is a winner, print “ Jill wins”
If they tie, print “tie”
Ps: you can combine conditions using and / or
