Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Recap Quiz

Total questions: 120

Worksheet time: 1hrs 5mins

Name
Class
Date
1.

_______ is a data type that contain a set of characters (letters, symbols, etc.) E.g. "Hello", "Ali", "Car Type"

a)

int

b)

float

c)

char

d)

String

2.

Which value is of data type String?

a)

64

b)

"Cat"

c)

True

d)

0.5

3.

What is a Float?

a)

A data type that contains whole numbers. E.g. 3, 45, 124

b)

Numbers with decimal point. E.g. 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. E.g. "Table"

d)

Data type that can only be True or False.

4.

Which value is of data type Float?

a)

64

b)

"Cat"

c)

True

d)

0.5

5.

What is an Integer?

a)

A data type that contains whole numbers. E.g. 3, 45, 124

b)

Numbers with decimal point. E.g. 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. E.g. "Table"

d)

Data type that can only be True or False.

6.

Which value is of data type Integer?

a)

64

b)

"Cat"

c)

True

d)

0.5

7.

What is a Boolean?

a)

A data type that contains whole numbers. E.g. 3, 45, 124

b)

Numbers with decimal point. E.g. 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. E.g. "Table"

d)

Data type that can only be True or False.

8.

Which value is a Boolean?

a)

64

b)

"Cat"

c)

True

d)

0.5

9.

Which of the values below is an integer data type?

a)

1

b)

1.0

c)

1/2

d)

"1"

10.

_____ is a data type that contains a single character such as A, a, Z, z etc.

a)

int

b)

float

c)

char

d)

String

11.

_____ is a data type that can represent one of two values either True or False such as 1, 0, 2 > 1, 3 < 2.

a)

int

b)

float

c)

char

d)

Boolean

12.

Which of the values below is a float data type?

a)

2

b)

2.11

c)

2/4

d)

"2.11"

13.

Which of the values below is a char data type?

a)

firstValue

b)

F

c)

1.0

d)

10 > 3

14.

Which of the values below is a string data type?

a)

firstValue

b)

F

c)

1.0

d)

10 > 3

15.

Which of the values below return TRUE if executed?

a)

10 > 3

b)

10 < 3

c)

10 >< 3

d)

10 <> 3

16.

Which of the values below return FALSE if executed?

a)

10 > 3

b)

10 < 3

c)

10 >< 3

d)

10 <> 3

17.

Which of the values below return FALSE if executed?

a)

1

b)

0

c)

-1

d)

-50

18.
Which data type is used to store:
100
a)
Integer
b)
Double
c)
Boolean
d)
String
19.
Which data type is used to store:
"D"
a)
Character
b)
String
c)
Integer
d)
Double
20.
This data type is used to store a mixture of letters and numbers and symbols.
a)
String
b)
Character
c)
Boolean
d)
Integer
21.

Which of the following is a list data type?

a)

[1, "Hello", 5.0, "World"]

b)

(True, 20)

c)

"Greetings"

d)

200.0

22.

List is a collection which is ordered and changeable.

a)

True

b)

False

23.

What data type is the following?

[70, 80, 90, 100]

a)

Integer

b)

Float

c)

List

d)

String

24.

What is the process of converting one data type to another called?

a)

Data conversion.

b)

Type Casting.

c)

Type Conversion.

d)

Concatenation.

25.

What function converts the data in a variable into a 'integer'?

a)

int()

b)

str()

c)

bool()

d)

float()

26.

What function converts the data in a variable into a 'float'?

a)

int()

b)

flt()

c)

bool()

d)

float()

27.

What function converts the data in a variable into a 'string'?

a)

str()

b)

float()

c)

bool()

d)

string()

28.

What does this built-in function do?

input()

a)

Opens the CD tray.

b)

Prompts the user to enter data.

c)

Displays the word 'input'.

d)

Exits the program.

29.

How do you ask for the user to input their name?

a)

name = int("what is your name")

b)

print("What is your name?")

c)

input = name("what is your name?")

d)

name = input("what is your name?")

30.

By default any data inputted by the user is of data type string in python.

a)

True

b)

False

31.

What will be the output of the following command?

x = int(3.6)

print(x)

a)

3

b)

4

c)

Logical error - Can't cast a float value to an integer as data will be lost.

32.

What will be the output of the following command?

x = float(3)

print(x)

a)

Logical error - Can't cast a integer value to an float as data will be added.

b)

3.0

c)

3

33.

What will be the output of the following command?

x = str(3)

print(x)

a)

3

b)

3.0

c)

'3'

34.

What will be the output of the following program, if the user entered 20 and then 41?

Number1 = input("Enter the first number: ")

Number2 = input("Enter the second number: ")

print(Number1 + Number2)

a)

20 41

b)

Syntax error.

c)

61

d)

2041

35.

What can you add to the following code so that python recognises that they are numbers?

Number1 = input("Enter the first number: ")

Number2 = input("Enter the second number: ")

print(Number1 + Number2)

a)

int()

b)

float()

c)

Use a print statement to tell the user to enter a number.

d)

integer()

36.

Fill in the missing section for the code below:

areaOfSquare = (a)   (input("Enter area of square: "))

37.

What will be the output of the following program?

gameOnePoints = 200

gameTwoPoints = "456"

print(gameOnePoints + gameTwoPoints)

a)

Logical error - Can't add an integer and string together.

b)

656

c)

"656"

38.

Enter the missing keyword for the program below:

name =_____("Enter name: ")

a)

input

b)

print

c)

Bob

d)

Input

39.

What is the name of the built-in command in python to output data?

a)
print
b)
input
c)

Print

d)

display

40.

What will be the output for the following python programme:

name = "Dave"

print(name)

a)
Dave
b)
'Dave'
c)
name
d)
(name)
41.

What will be the output for the following python programme:

name = "Dave'

print(name)

a)
Dave
b)
'Dave'
c)

Syntax error

d)

Name

42.

What is a input?

a)

A built-in function that allows us to prompt the user to enter data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A device.

43.

What syntax would you use to create a name variable?

a)

name=input()

b)

input=name

c)

name=input{}

d)

name=INPUT

44.

What is the proper syntax for Python comments?

a)

<!-- Python comment -->

b)

<comment> Python comment <comment>

c)

# Python Comment

d)

/* Python Comment */

45.
What symbol is used in python to assign values to a variable?
a)

=

b)

+ 

c)

==

d)

*

46.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)

Syntax Error

d)
Hello world!
47.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)

Syntax Error

48.

What does the following code do? myAge = int(myAge)

a)

Converts the variable myAge to a integer

b)

Syntax Error

c)

Converts the variable myAge from a integer to a string

d)

Missing input

49.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
50.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
51.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
52.

Are Double or single quotes used in Python?

a)

Double

b)

Single

c)

Neither

d)

Both work

53.

Which of the following assign the value 50 to a variable x?

a)

x=50

b)

Let x=50

c)

x;=50

d)

x<<50

54.

Python correct naming convention for variables is?

a)

new_user25

b)

NewUser25

c)

25_new_user

d)

25NewUser

e)

NEWUSER25

55.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

d)

4

56.
What will the output be from the following code?
Print("Hello world!")
a)

Name Error

b)
Hello world!
c)
"Hello world"
d)
Print(Hello world!)
57.
What will the output be from the following code?
print("Hello" + 2 + "world")
a)
Hello 2 world
b)
Hello2world
c)
TypeError
d)
HelloHelloworld
58.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
59.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
60.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

61.

What will be the output for following python programme:

x = 100

y = float(x)

print(y)

a)

200

b)

100.0

c)

100

d)

Can't convert an integer to a floating number.

62.

A named memory location used to store values in computer is a ...

a)

Casting

b)

String

c)

Variable

d)

Hard Drive Disk

63.

Choose three properties of a variable below:

a)

Has a name.

b)

Holds a value.

c)

Has a data type.

d)

Has a length.

64.

Choose variable rules from the list below:

a)

Must not begin with a number

b)

Can only contain (A-Z, a-z) and 0-9 characters, and _

c)

Can use _ to join words separated words

d)

Must be in lower case

65.

In what way is a constant different from a variable?

a)

It can store more than one value

b)

It does not change its value during program execution

c)

Its name should be written in UPPER CASE so it can be easily identified as a constant

66.

The process of giving a value to a variable is ...

a)

Allocation

b)

Assignment

c)

Comparison

d)

Debugging

67.

Choose valid variable names from the list of options given below:

a)

1st_name

b)

Last_name

c)

first Name

d)

f1_name

e)

firstName

68.

Num = 90

Num = 20

print(Num)

a)

90

b)

4.5

c)

20

d)

1800

69.

In the following code, what type of variable is being created?

foo = "bar"

a)

Integer

b)

Float

c)

String

70.

In the following code, what value will be assigned to the variable "cat"?


mouse, cat, dog = "small", "medium", "large"

a)

small, medium, large

b)

small

c)

medium

d)

large

e)

Nothing, that operation will throw an error

71.

In the following code, what value will be assigned to the variable "cat"?


mouse + cat + dog = "small" + "medium" + "large"

a)

small, medium, large

b)

small

c)

medium

d)

large

e)

Nothing, that operation will throw an error

72.

Looking at the following code, what are the names of the variables:

a)

firstName, lastName, fullName

b)

Hyperion, Hub

c)

firstName, lastName, fullName, space

d)

FIRSTNAME, LASTNAME, FULLNAME, SPACE

73.

What rule is the following variable name BREAKING:


1st_Name

a)

No special characters other than underscore

b)

Only use text for the start of the variable name - no numbers at start

c)

Keep names meaningful

d)

There is nothing wrong with this variable name

74.

What rule is the following variable name BREAKING?


StudentNo.

a)

Only use text for the starting letter of a variable name - not numbers at the start

b)

No special symbols other than the underscore

c)

There is nothing wrong with this variable name

d)

Keep variable names meaningful for the task they are being used for

75.

Which name would be meaningful in keeping a record of someone's high score?

a)

s

b)

hs

c)

score

d)

highScore

76.

Which of the below are acceptable variable names?

a)

result final = 5

b)

result-final = 1

c)

resultFinal = 3

d)

result#final = 4

77.
The correct way to write a variable in Python?
a)
myVariable = 10
b)
my Variable = 10
c)
myVariable is 10
d)
myVariable: 10
78.
In programming, what is iteration?
a)
The repetition of steps within a program
b)
The order in which instructions are carried out
c)
A decision point in a program
d)
Testing a program to make sure it works
79.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
d)
It ensures the code works correctly
80.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
81.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
82.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
83.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
84.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
85.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
86.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
87.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
88.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
89.
a)
10  8  6  4  2
b)
10
8
6
4
2
c)
2  4  6  8  10
d)
10  9  8  7  6  5  4  3  2  1
90.
a)
12  9  6  3  0
b)
0  3  6  9  12
c)
9  6  3  0
d)
0  3  6  9
91.
a)
0  5  10
b)
5  10
c)
0  5  10  15  20  25  30  35  40  45  50  55  60  65  70  75  80  85  90  95  100  105  110  115  120  125  130  135  140......etc
d)
12  7  2
92.
a)
12  17   22
b)
5
c)
12
d)
5  10
93.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
94.
a)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
b)
Hello world!
c)
Hello world!
break              
d)
Error
95.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
96.
a)
Hello world!
b)
Error
c)
Hello world!
False
d)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
97.
a)
Welcome
b)
Try again!
c)
Error
d)
Enter your password
98.

What does the following comparison operator “==” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

99.

What does the following comparison operator “!=” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

100.

What does the following comparison operator “>” represent in Python programming?

a)

Equal to

b)

Greater than

c)

Less than

d)

Not equal to.

101.

What does the following comparison operator “<” represent in Python programming?

a)

Equal to

b)

Greater than

c)

Less than

d)

Not equal to.

102.

What does the following comparison operator “>=” represent in Python programming?

a)

Greater than

b)

Greater than or equal to

c)

Greater than and equal to

d)

Less than or equal to

103.

What does the following comparison operator “<=” represent in Python programming?

a)

Greater than

b)

Greater than and equal to

c)

Less than

d)

Less than or equal to

104.

What is the name of the following logical operator?

Returns True if both statements are true

(a)  

105.

What is the name of the following logical operator?

Returns True if one of the statements is true

(a)  

106.

What is the name of the following logical operator?

Reverses the result, returns False if the result is True

(a)  

107.

What is the result of the following condition if x = 3?

not(x < 5 and x < 10)

a)

True

b)

False

108.

What is the result of the following condition if:

A = 30

B = 21

C = 71

(A > B and A > C) or B < C

a)

True

b)

False

109.

What is the result of the following condition if:

A = 30

B = 21

C = 71

not(B < A and B < C)

a)

True

b)

False

110.

What is the result of the following condition if:

A = 30

B = 21

C = 71

B != A or C < A

a)

True

b)

False

111.

Write down the line number in which the first decision is used.

(a)  

112.

What would be outputted here?

a)

Bigger than 2!

b)

Number is 5

c)

Bigger than 2!

Number is 5

d)

Nothing

113.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

114.

What is the correct syntax for an if statement in Python?

a)

if (condition) {code block}

b)

if condition: code block

c)

if condition then code block

d)

if [condition] {code block}

115.

How do you write an if statement to check if `x` is greater than 10?

a)

if x > 10:

b)

if x is > 10:

c)

if x >> 10:

d)

if x gt 10:

116.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

117.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

118.

What will this program output?

a)

:(

b)

":("

c)

Error

d)

nothing

119.

What would be outputted here?

a)

it divides by 7!

b)

it divides by 3!

c)

It divides by 7.

d)

It divides by 3.

120.

What would be outputted here?

a)

WHY!

b)

An error

c)

WHY!!

d)

You have a good taste.