NEW
Font size
WorksheetsYear 8 CAT
Total questions: 40
Worksheet time: 3600secs
What will be the result of the code below
x, y, z = "Orange", "Banana", "Cherry"
print(x)
"Orange", "Banana", "Cherry"
"Banana",
"Banana", "Cherry"
"Orange"
x = y = z = "Mango"
print(x)
print(x)
"Mango"
banana
orange
What is the result of the code below?
fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(z)
"apple"
"cherry"
banana
None
The Python print statement is often used to output variables.
True
False
None
Run the code below
x = "awesome"
print("Python is " + x)
"Python awesome is "
"awesome is "
"Python
Python is awesome
None
x = "Python is "
y = "awesome"
z = x + y
What code will you write to bring out the result of z
print(z)
print(x)
print(y)
print(yz)
x = "awesome"
def myfunc():
print("Python is " + x)
myfunc()
"Python is
"Python is awesome"
"Python is banana"
"Python is apple"
When you create a variable inside a function, that variable is local, and can only be used inside that function.
True
False
None
All
What type of variable is this?
myVariableName = "John"
Pascal Case
Camel Case
Snake Case
All
Is this variable name acceptable?
2myvar = "John"
Yes
No
I dont know
Change the following line of code to a comment.
print("Hello World")
+print("Hello World")
#print("Hello World")
&print("Hello World")
print("Hello World")
Which of the following Python operators is used for variable assignment?
=
+
/
*
Which of the following is not a data type in Python?
Integer
String
Float
Figures
What do we use the float() function for?
To change a value to float
To change a value to a string
To change a value to an integer
None of the Above
What is the output of the following code on the Python Shell?
a = 10
b = 2
c = a/b
print(c)
2
4
1
5
What is the output of the following code on the python shell 5+3-5?
3
-3
5
-5
What type of comment can you see below?
#This is a comment
#written in
#more than just one line
Line comment
commenters
comment
Multi Line comment
________ is a container for storing data.
Comment
Variable
Casting
None
One of the following is the reason for adding comment to lines of codes.
To make to code run faster
To make the code readable
To make the code looks funny
None of the above
What was your first code written in this program?
print("Hello,World")
Print ("Hello, World")
print ("Hello, World)
str(3)
int(5 .5)
The codes above are examples of ______.
Line Comment
Variable
Variable names
Casting
Look at the code below
A=5
B=10
A=7
print(A+B)
What will be the output?
27
17
15
10
Is this a legal variable name?
my_name
True
False
Not sure
Is variable name case sensitive?
Yes
No
String variables can be declared either by using single or _______ quotes.
Multiple
Double
Frequent
Lonely
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
WHILE 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
A condition is
a statement that is either True or False
a string
an integer
a list
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to £100.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a program that will keep letting me add a monthly payment for 12 months.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a guessing game program that will let me keep guessing until I get the right answer.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a revision program that will run through revision questions 4 times.
FOR Loop
WHILE Loop
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
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
what is the name of the variable used in the following code?
counter
for
#
