WorksheetsរំឮកមេរៀនPython
Total questions: 45
Worksheet time: 23mins
In Python, what are if-statements used for?
Looping
Indexing
Decision Making
Testing
What is the output of this code?
click = True
Like = 0
if click:
Like = Like + 1
print(Like)
0
1
2
3
What is the output of the following code?
What is the output of following code
Temperature = 20
Thermo = 15
if Temperature < 15:
Thermo = Thermo + 5
print(Thermo)
20
15
25
10
print("Hello" + str(2) + "world!")
print(Hello world!)
print("Hello world!" * 2)
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
If the user enters 60, what is the output?
You are old!
You are middle-aged!
You are young!
Error message
What term is used to describe data passed into/out of a program?
Variable
Loop
Constant
Parameter
Consider the line of code:
Label('Go Team', 200, 100)
What is the Label?
argument
parameter
function name
Consider the line of code:
Label('Go Team', 200, 100)
What is 'Go Team' ?
argument
parameter
function name
Which of these codes is correct for creating a list of numbers?
num = ('10','29','37','109')
num = ['10','29','37','109']
num == ('10','29','37','109')
num = ['10 29 37 109']
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
Why is using lists beneficial?
Shorter Code
More Accurate
It takes less time for the program to run
Its not beneficial
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
What does the '#' allow you to do?
Repeat code
Comment on code
Print code
End code
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
data = "No Way!" The expression len(data) evaluates to:
7
9
8
6
Which is the most appropriate data type for: "13th December"
Float
Boolean
Integer
String
What will the output be from the following code?
print("3+4")
7
34
3+4
SyntaxError
print("12"*3)
What would this print?
121212
36
24
12*3
What is a Count-Controlled loop?
for loop
while loop
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
What will be the output of this code?
1,2,3,4,5,6,7,8,9,10,11,12
0,2,4,6,8,10
2,4,6,8,10,12
2,4,6,8,10
Which of these will allow me to count from 0-20 in steps of 5?
for x in range(0,20):
print(x)
while x = (0,20,5):
print(x)
for x in range(0,21,5):
print(x)
for x in range(0,21,5):
print(y)
What is the error in this code?
incorrect variable name
incorrect indentation
incorrect speech marks
incorrect loop
How many variables are there in this program?
2
3
4
5
What type of list is being used in this example?
Dictionary
List
Tuple
2d Array
What you the output of this program be if the user guessed "h"?
Error
It was heads
It was tails
Bad luck
How many errors are there in this piece of code?
0
1
2
3
Which of these is a list?
fruit = ["apples", "oranges", "bananas"]
fruit = "apples", "oranges", "bananas"
fruit = {"apples", "oranges", "bananas"}
fruit = ("apples", "oranges", "bananas")
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
An empty list can be declared as
fruitList = ""
fruitList = ["empty"]
fruitList == []
fruitList = []
Which of the following commands will return the length of the list mylist?
length(mylist)
len(mylist)
mylist.length()
mylist.len()
write code that will ask a user to enter a number and store it in the variable x. You should do any necessary typecasting in-line. Make your prompt say "Enter a number".
(a)
