WorksheetsVariables, Arrays, For Loops, and Functions Review
Total questions: 35
Worksheet time: 21mins
In computers science, variables:
are numbers like pi
represent parts of an experiment that are measured or tested
are placeholders for storing information
are unchangeable
I can name my variable player1
True
False
I can name my variable player 1
True
False
Which of the following variables is NOT string type?
character = "Dr."
vehicle = "Ambulance"
speed = 27
lives = "3"
What would be the new value of a after running the program:
var a = 3;
var b = 5;
a = a*b;
8
3
15
75
What would be the value of "var_x" after this statement runs: var_x = 4+2
3
4+2
6
12
What would be the value of "var_x" after this statement runs: var_x = "3+3"
3
3+3
6
var_x = "3+3"
Which of these is a list?
fruit = ["apples", "oranges", "bananas"]
fruit = "apples", "oranges", "bananas"
fruit = {"apples", "oranges", "bananas"}
fruit = ("apples", "oranges", "bananas")
names = ["Paul","Phillip","Paula","Phillipa"]
In a list called "players", if you wanted to add a player called "Bob" to the list, which of the following examples of code would be correct in Python?
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
What does the '#' allow you to do?
Repeat code
Comment on code
Print code
End code
An empty list can be declared as
fruitList = ""
fruitList = ["empty"]
fruitList == []
fruitList = []
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
What does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
When do you know when you come to the end of the loop?
Its states End loop
The command End is given
The indentation stops
if you wished a loop to repeat 3 types whwt should you use?
For counter in range(0,5):
For counter in range(1.3):
For counter in range(0.3):
what is the name of the variable used in the following code?
counter
for
#
What is the purpose of a function?
They are reusable pieces of programs.
They are required by the Python
They allow us to compile our program
They make the program larger
Which keyword is used for functions?
func
def
define
function
What term is used to describe data passed into a function?
Variable
Loop
Constant
Parameter
Leo wants to create a function that will roll a dice. Which is the correct function definition header?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
