WorksheetsPython Y10
Total questions: 29
Worksheet time: 21mins
print(Hello world!)
print(3*4+5)
What symbol is used in python to assign values to a variable?
=
+
/
==
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
word= "computer"
for num in range(1,6):
print(word)
for loopCounter in range(10,101,10):
print(loopCounter)
4
3
2
1
3
2
1
0
4
3
2
1
3
2
1
0
2
11
2
21
2
3
11
2
3
21
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
The list needs one more name added to the end - "Felipe". Which piece of code below would do this?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList.append(Felipe)
append(nameList,"Felipe")
nameList.append["Felipe",7]
nameList.append("Felipe")
To insert an the string "strawberries" in the first position of a list we use
fruit.append("strawberries, 1")
fruit.insert("strawberries",0)
fruit.insert(1, "strawberries")
fruit.insert(0, "strawberries")
randItem = random.choice(["gold", "silver", "platinum"])
could select either gold, silver or platinum
will select gold
will select silver
will select platinum
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What is a function?
A section of code that will return a value
A section of code that will return nothing
A section of code that will return a command
None of the above
What is a Procedure?
A section of code that will return a value
A section of code that will return nothing
A section of code that will return a command
None of the above
What is a benefit of using Subroutines?
More efficient
Takes longer to write
The code looks better
The program executes better
Parameter
A named block of code designed to carry out a specific task.
A named block of code that returns a value.
Identifies data being passed into a subroutine.
An item of data being passed to a subroutine.
Argument
A named block of code designed to carry out a specific task.
A named block of code that returns a value.
Identifies data being passed into a subroutine.
An item of data being passed to a subroutine.
How many parameters are being passed into the function add?
0
1
2
3
