wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

EDX python 06

Total questions: 80

Worksheet time: 1hrs 8mins

Name
Class
Date
1.
A line of text that Python won't try to run as code
a)
comment
b)
modulus
c)
variable
d)
boolean
2.
Symbol used for modulus
a)
%
b)
&
c)
#
d)
**
3.
A data type than can have one of two values: True or False
a)
boolean
b)
variable
c)
modulus
d)
interpreter
4.
Used to make comments
a)
#
b)
%
c)
**
d)
()
5.
The correct way to write a variable in Python?
a)
myVariable = 10
b)
my Variable = 10
c)
myVariable is 10
d)
myVariable: 10
6.
10= 100
Which of the following is used in Python to calculate ten squared?
a)
10 ** 2
b)
10 * 2
c)
10 % 2
d)
10 ** 10
7.
To solve a problem that requires the user to enter 10 numbers would use what type of iteration?
a)
While loop
b)
For loop
c)
Variable
d)
Selection
8.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
9.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
10.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
11.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
12.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
13.
What will the output be from the following code?
print("Hello" + "world!")
a)
Hello world!
b)
Helloworld!
c)
SyntaxError
d)
"Hello" "world!"
14.
Which Python command is used to output information to the screen?
a)
read
b)
output
c)
print
d)
display
15.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

there is no variable

16.

What will happen when this program is run?

a)

Syntax error

b)

One will be displayed

c)

Zero will be displayed

d)

One then Zero will be displayed

17.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

18.

What will the code do?

a)

nothing

b)

display Hello Bob

c)

display I don't know you

d)

display Hello

19.

What will happen when this program is run?

a)

Syntax error

b)

One will be displayed

c)

Zero will be displayed

d)

One then Zero will be displayed

20.

What will happen when this program is run?

a)

Syntax error

b)

Big will be displayed

c)

Small will be displayed

d)

300 will be displayed

21.

If the user enters 60, what is the output?

a)

You are old!

b)

You are middle-aged!

c)

You are young!

d)

Error message

22.
What does “==” represent in Python programming?
a)
less than
b)
equal to
c)
greater than
d)
not equal to
23.
Choose the correct Python code.
if age is less than 20 then
a)
if age > 20:
b)
if age < 20:
24.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

25.

Select the correct Operator for addition

a)

+

b)

=

c)

X

d)

$

26.

Select the correct operator for subtraction:

a)

*

b)

-

c)

_

d)

*

27.

Select the correct operator for multiplication:

a)

x

b)

*

c)

**

d)

+

28.

Select the correct operator for division:

a)

/

b)

\

c)

"

d)

!

29.

Select the correct operator for Modulus:

a)

?

b)

/

c)

>

d)

%

30.

Select the correct operator for Floor Division (Div):

a)

//

b)

\\

c)

%%

d)

--

31.

Select the correct operator for Exponentiation:

a)

**

b)

))

c)

XX

d)

==

32.

Select the correct answer:


x = 15

y = 4


print( 'x * y')

a)

59

b)

60

c)

54

d)

22

33.

Select the correct answer:


x = 15

y = 4


print(x // y)

a)

3

b)

3.75

c)

4

d)

5

34.

Select the correct answer:


x = 15

y = 4


print('x ** y =',x**y)

a)

50625

b)

45658

c)

50621

d)

50254

35.

Comparison Operators:


Select the correct operator for Greater Than:

a)

>

b)

<

c)

^

d)

v

36.

Comparison Operators:


Select the correct operator for Less than

a)

>

b)

<

c)

^

d)

v

37.

Comparison Operators:


Select the correct operator for equals to

a)

=

b)

==

c)

===

d)

====

38.

Comparison Operators:


Select the correct operator for not equal to

a)

=!=

b)

!

c)

=!

d)

!=

39.

Comparison Operators:


Select the correct operator for Greater than or Equal to:

a)

>=

b)

=>

c)

=)

d)

<=

40.

Comparison Operators:


Select the correct operator for less than or equal to

a)

<=

b)

=>

c)

>=

d)

==

41.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
42.
This operator means that one value is not equal to another value
a)
==
b)
<=
c)
>=
d)
!=
43.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

44.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

45.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

46.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

47.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

48.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

49.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

50.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

51.

What is the output?

a)

level 3

b)

level 3

level 1

c)

level 3

level 1

NIL

d)

level 3

level 2

level 1

NIL

52.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
53.

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

a)

Yes

b)

No

54.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3

55.

What is the output of program below?


bicycles = ['trek', 'cannondale', 'redline', 'specialized']

print(bicycles[-1])

a)

trek

b)

cannondale

c)

redline

d)

specialized

56.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
57.
What is the position of the name "Robert" in the following list:
a)
0
b)
1
c)
2
d)
3
58.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
59.
Each item in a list has an "address" or index. The first index in a Python list is what?
a)
0
b)
1
c)
a
d)
A
60.

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?

a)

players.pop[3]

b)

players.delete(3)

c)

players.remove(3)

d)

players.pop(3)

61.
If you want to create an empty list called colours, which of the following pieces of code is correct?
a)
colours = [ ]
b)
colours = ( )
c)
colours = { }
d)
colors = [ ]
62.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
63.
What output will this code produce?
a)
red
b)
['blue', 'green', 'red']
c)
['red', 'green', 'blue']
d)
error
64.
What output will this code produce?
a)
['blue', 'green', 'red', 'yellow']
b)
['blue', 'red', 'yellow']
c)
['yellow', 'red', 'green']
d)
['yellow', 'red', 'blue']
65.

What will line 3 OUTPUT?

a)

3

b)

2

c)

TRUE

d)

FALSE

66.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

67.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

68.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

69.

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"]

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

70.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
71.

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

a)

Yes

b)

No

72.

Consider this list, what will be the highest index the list can have:

li=[1,2,3,4,5]

a)

2

b)

3

c)

4

d)

5

73.

The count() method returns the number of times the specified element appears in the list.

What is the output of this code?

a)

3

b)

2

c)

1

d)

0

74.

Output of this code?

a)

[2,4,6,8,10]

b)

['2','4','6','8','10']

c)

[0,2,4,6,8]

d)

[10,8,6,4,2]

75.

What is the output of this code?

a)

X

b)

Y

c)

Error

76.

Which of the following function is used to count the number of elements in a list ?

a)

count( )

b)

find( )

c)

len( )

d)

index( )

77.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3

78.

mylist = ["a","b"]

mylist[1] = "c"'

print(mylist)

a)

["a","c"]

b)

["a","b"]

c)

["a","b","c"]

d)

mylist

79.

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!")

a)

Yes, 'triangle' is in the list

b)

"No triangle here!"

80.

What is the output of program below?


bicycles = ['trek', 'cannondale', 'redline', 'specialized']

print(bicycles[-1])

a)

trek

b)

cannondale

c)

redline

d)

specialized