WorksheetsEDX python 06
Total questions: 80
Worksheet time: 1hrs 8mins
Which of the following is used in Python to calculate ten squared?
print(Hello world!)
print(3+4)
print("3+4")
print("Hello" + "world!")
What is the name of the variable in this program?
colour
input
there is no variable
What will happen when this program is run?
Syntax error
One will be displayed
Zero will be displayed
One then Zero will be displayed
What will this code print?
access denied
access granted
error
password
What will the code do?
nothing
display Hello Bob
display I don't know you
display Hello
What will happen when this program is run?
Syntax error
One will be displayed
Zero will be displayed
One then Zero will be displayed
What will happen when this program is run?
Syntax error
Big will be displayed
Small will be displayed
300 will be displayed
If the user enters 60, what is the output?
You are old!
You are middle-aged!
You are young!
Error message
if age is less than 20 then
What is the output?
next
stop
next
stop
syntax error - program doesn't work
Select the correct Operator for addition
+
=
X
$
Select the correct operator for subtraction:
*
-
_
*
Select the correct operator for multiplication:
x
*
**
+
Select the correct operator for division:
/
\
"
!
Select the correct operator for Modulus:
?
/
>
%
Select the correct operator for Floor Division (Div):
//
\\
%%
--
Select the correct operator for Exponentiation:
**
))
XX
==
Select the correct answer:
x = 15
y = 4
print( 'x * y')
59
60
54
22
Select the correct answer:
x = 15
y = 4
print(x // y)
3
3.75
4
5
Select the correct answer:
x = 15
y = 4
print('x ** y =',x**y)
50625
45658
50621
50254
Comparison Operators:
Select the correct operator for Greater Than:
>
<
^
v
Comparison Operators:
Select the correct operator for Less than
>
<
^
v
Comparison Operators:
Select the correct operator for equals to
=
==
===
====
Comparison Operators:
Select the correct operator for not equal to
=!=
!
=!
!=
Comparison Operators:
Select the correct operator for Greater than or Equal to:
>=
=>
=)
<=
Comparison Operators:
Select the correct operator for less than or equal to
<=
=>
>=
==
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
What is the output of program below?
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles[-1])
trek
cannondale
redline
specialized
In a list called "players" if you wanted to delete the item with an index of 3 which of the following examples of code would be correct?
players.pop[3]
players.delete(3)
players.remove(3)
players.pop(3)
What will line 3 OUTPUT?
3
2
TRUE
FALSE
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]
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"
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
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")
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
Consider this list, what will be the highest index the list can have:
li=[1,2,3,4,5]
2
3
4
5
The count() method returns the number of times the specified element appears in the list.
What is the output of this code?
3
2
1
0
Output of this code?
[2,4,6,8,10]
['2','4','6','8','10']
[0,2,4,6,8]
[10,8,6,4,2]
What is the output of this code?
X
Y
Error
Which of the following function is used to count the number of elements in a list ?
count( )
find( )
len( )
index( )
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
mylist = ["a","b"]
mylist[1] = "c"'
print(mylist)
["a","c"]
["a","b"]
["a","b","c"]
mylist
What would the output of the program be?
thisList = ["square", "circle", "triangle", "octagon"]
if "triangle" in thisList:
print("Yes, 'triangle' is in the list")
else:
print("No triangle here!")
Yes, 'triangle' is in the list
"No triangle here!"
What is the output of program below?
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles[-1])
trek
cannondale
redline
specialized
