Font size
WorksheetsPython Quiz
Total questions: 15
Worksheet time: 5mins
What do For Loops do?
A programming structure used to repeat actions without the player needing to write the same lines of code over and over.
Data about or belonging to an object.
Repeat a block of code while a certain condition is true.
Repeat a block of code a certain number of times.
What will the following code output?
myTuple = [(1, 2), (3, 4), (5, 6)]
for (a, b) in myTuple :
- print(a + b)
1,2,3,4,5,6
1,3,5
2,4,6
3,7,11
for letter in "12345":
- if letter == 3:
-- break
- print(letter)
1,2,4,5
1,2
1,2,3,4,5
Error
print(Hello world!)
What do while Loops do?
A programming structure used to repeat actions without the player needing to write the same lines of code over and over.
Data about or belonging to an object.
Repeat a block of code while a certain condition is true.
Repeat a block of code a certain number of times.
choose the right variable name :
var1 = 5
vA_r = 5
var-1 = 5
1var = 5
var 1 = 5
x = {"apple", "banana", "cherry"}
what is the type of x ?
tuple
list
set
dictionary
which one is the smallest unit ?
module
library
package
x = lambda a : a + 10
print( x(5) )
50
15
51
25
Returns a random float number between 0 and 1
random()
shuffle()
randint()
sample()
Opens a file for writing, creates the file if it does not exist
"r"
"a"
"w"
"x"
What will be the output of: print ("3+57")
3 + 57
90
60
3+57
What is the output of the following code?
x = 10
# x = 2 * x
print(x)
20
10 10
210
10
