wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Final Test Review

Total questions: 92

Worksheet time: 51mins

Name
Class
Date
1.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
2.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
3.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
4.

What will the output be from the following code? print("Hello" + str(3) + "world!")

a)
Hello world! Hello world!
b)
Hello2world!
c)

Hello3World!

d)

Hello Hello Hello world world! world!

5.

Which function/command will change the current working directory

a)

os.getcwd

b)

os.changedir

c)

os.mkdir

d)

os.chdir

6.

What code will execute a new sub-directory called "new_student"

a)

os.mkdir('new_student')

b)

import os

os.mkdir('new_student')

print(os.listdir())

c)

import os

os.chdir('new_student')

print(os.listdir())

d)

os.chdir('new_student')

7.
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
8.
Used to create exponents
a)
**
b)
"""
c)
%
d)
#
9.

What will be the output? name = 'Isiah' print (name)

a)

Isiah

b)

'Isiah'

c)
name
d)
(name)
10.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
11.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
12.
What is the correct definition for a VARIABLE?
a)
a changeable value, such as a score in a computer game.
b)
a value that cannot be changed
13.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
14.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2
15.

There are 40 students in a classroom. We would like to get all students whose name starts with "A". Which looping is suitable?

a)

For loop

b)

While loop

16.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
17.

Python is _____ sensitive which means you must use the same indentation every time.

a)

space

b)

colour

c)

code

d)

word

18.

people = ["Larry", "Rob", "Kacy", "Joe"]

print (people[4])

what would this result be?

a)

Larry

b)

Joe

c)

Kacy

d)
Error
19.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
20.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
21.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
22.

people = ["Tony", "Yasmin", "Henry", "Sam"]

print (people[-1])

what would this result be?

a)

Tony

b)

Yasmin

c)

Henry

d)

Sam

23.

What will the output be for the code shown here?

for count in range (3,0,-1)

print(count)

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

24.

What will the output be from the following code? print(3*4+6)

a)

17

b)

18

c)
12
d)
SyntaxError
25.

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

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

26.
symbol used for modulo
a)
%
b)
&
c)
#
d)
**
27.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
28.

Which statement will print the content of the current directory in list format?

a)

os.listdir()

b)

os.listdirectory()

c)

os.getcwd()

d)

import os.listdir()

29.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
30.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
31.
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)
SyntaxError
d)
Hello world!
32.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
33.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
34.

The correct way to convert user input is:

a)

birth_year = number(input())

b)

birth_year = int(input())

c)

birth_year = (input(int))

d)

birth_year = int(input)

35.

Python is _____ sensitive which means you must use the same indentation every time.

a)

space

b)

colour

c)

code

d)

word

36.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

37.
a line of text that Python won't try to run as code
a)
comment
b)
modulo
c)
variable
d)
boolean
38.

What is an instruction?

a)

A box in a flowchart

b)

A calculation performed in a programming language

c)

One or more statements grouped together to instruct the computer to perform a task

d)

A separate file that has information on how to install the program

39.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
40.

Patients visit hospital everyday. You want to count for the "new patients" for each day. Which one is not necessary?

a)

Set

b)

While loop

c)

For loop

d)

Set difference

41.

What will be the output?

name = 'Ralph'

greeting = "Good Bye" + name

print (greeting)

a)

Good bye 'Ralph'

b)

Good bye Ralph

c)

Greeting

d)

Good bye + Ralph

42.

Which has integer data type?

a)

Phone number

b)

Zip code

c)

HN

d)

Number of students in the class

43.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

44.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
45.

How do we get user input from the keyboard?

a)

input = (What is your name?)

b)

input = What is your name?

c)

output = ("What is your name?")

d)

input("What is your name? ")

46.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
47.

What is the output of the following program?

for i in range(0, 5):

print(i)

i=i+1

a)

1 to 5 numbers

b)

1 to 4 numbers

c)

0 to 4 numbers

d)

0 to 5 numbers

48.

Displays the abbreviated month name:

a)

%m

b)

%b

c)

%a

d)

%d

49.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

50.
what is the code for a STRING in python?
a)
str
b)
stri
c)
stg
51.

A FOR loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

52.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
53.

Which function/command returns the current date and time?

a)

datetime.now()

b)

.now()

c)

timedelta.now()

d)

.today()

54.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
55.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
56.

What function/command returns the current date

a)

datetime()

b)

.now()

c)

.currentdate()

d)

.today()

57.
includes numbers and booleans
a)
data types
b)
whitespace
c)
modulo
d)
comments
58.

If the coding steps are in the incorrect order, the computer can still execute the program.

a)

True

b)

False

59.

Which rounding function will produce the following input 43.5 = 44

a)

floor

b)

ceil

c)

trunc

d)

round

60.
What is another word for 'iteration'?
a)
Selection
b)
Variable Assignment
c)
Repetition
d)
Sequencing
61.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
62.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
63.

Which word completes this sentence: "Iteration makes code more ___________"

a)

Complex

b)

Efficient

c)

Simple

d)

Straightforward

64.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
65.

Deletes the first matching value from the list

a)

.add

b)

.remove()

c)

.pop()

d)

.del()

66.

If you want multiple options for your code, what should you use (after if)?

a)

elif

b)

else

c)

if

67.

from datetime import date

dt = date(month = 10, day = 23, year = 2021)

print(dt.strftime("%b %d, %Y"))


What is the correct output?

a)

Tues, Oct 23

b)

10/23/21

c)

Oct 23, 2021

d)

23 Oct 2021

68.

What would the output be for the code shown here?

a)

0,1,2,3,4,5,6,7,8,9

b)

1,2,3,4,5,6,7,8,9,10

c)

0,2,4,6,8,10

d)

0,2,4,6,8

69.
a data type than can have one of two values: True or False
a)
boolean
b)
variable
c)
modulo
d)
interpreter
70.

Moves the pointer to the beginning of the file

a)

.seek(0)

b)

.write

c)

'w' and 'w+'

d)

.strip()

71.
used to structure code in Python
a)
whitespace
b)
comments
c)
booleans
d)
variables
72.
returns the remainder from division
a)
modulo
b)
exponments
c)
boolean
d)
variables
73.

Which decision statement will be triggered if the variable x is less than 20?

a)

if x > 20:

b)

if x <> 20:

c)

if x == 20:

d)

if x < 20:

74.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
75.

Which data type would you use for the quantity of stock in a shop?

a)

integer

b)

float

c)

string

d)

boolean

76.

A WHILE loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

77.

Clara is writing a program that will print out the first ten numbers of a times table (chosen by the user). Should she use....

a)

a FOR loop

b)

a WHILE loop

78.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
79.
what is 8%2
a)
0
b)
16
c)
24
d)
86
80.

What function/object represents a duration or difference between two dates or times

a)

timedate

b)

timedelta

c)

datetime

d)

datedelta

81.

if you receive a NameError when you run your program it means....

a)

A variable has been assigned before it has been referred to

b)

An incorrect name has been chosen

c)

A variable has been referred to before it has been assigned

d)

A language key word has been used

82.

If you want to change the data type to an integer which line of code would you use?

a)

int ("How much pocket money do you have?")

b)

input("How much pocket money do you have?")

c)

int(input("How much pocket money do you have?"))

d)

int = ("How much pocket money do you have?")

83.

If you want more than one option for your code, what do you use (after if)?

a)

elif

b)

else

c)

ifif

d)

if

84.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

85.

Which operator can be used to compare two values?

a)

==

b)

<>

c)

=

d)

><

86.

from datetime import time

t = time(17, 39, 10, 43)

print(t.strftime("%I:%M:%S %p"))


What is the correct output?

a)

17:39:10 PM

b)

17:39:10

c)

05:39:10 PM

d)

05:39:10 AM

87.
what are the advantages of python?
a)
free and open source 
b)
can do the work for you 
c)
easy 
88.

From where to start the pointer before offset

a)

.seek()

b)

.pop()

c)

range()

d)

.seek(whence)

89.

num1 = 3

num2 = "8"

What is the minimum code to mathematically add num1 to num2?

a)

num1 + str(num2)

b)

num1 + int(num2)

c)

int(num1) + int(num2)

d)

int(num1) + str(num2)

90.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
91.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

92.

What would the output of this code be if the user entered the value 70?

a)

Pass

b)

Fail

c)

Merit

d)

Distinction