wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Unit 1 and 2 REVIEW

Total questions: 55

Worksheet time: 32mins

Name
Class
Date
1.
What function would I use to display text?
a)
sum
b)
import
c)
print
d)
display
2.
What does a hashtag represent when using Python?
a)
red text
b)
float
c)
comment
d)
integer
3.
Choose what * performs.
a)
multiplication
b)
addition
c)
division
d)
subtraction
4.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
5.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
6.
How would you assign an integer to a variable?
a)
new_var = 4
b)
new_var == 4
c)
new_var = "4"
d)
new var "4"
7.
A _____________ expression is an expression that is either true or false. 
a)
boolean
b)
truth
c)
variable
d)
conditional
8.
Which Data Type represents a whole number?
a)
String
b)
Float
c)
Boolean
d)
Integer
9.
Which Data Type represents text?
a)
Boolean
b)
Integer
c)
String
d)
Float
10.
What function is used to let the user answer a question?
a)
Open
b)
Print
c)
Answer
d)
Input
11.
A syntax error in your code means:
a)
You have not used enough characters. 
b)
There was no defined index. 
c)
Python can't find a file to pass the code to. 
d)
There is an error with your typing and code structure. 
12.
What is the output of 
print ("Hello" , "world")
a)
Helloworld
b)
Hello world
c)
world hello
d)
hello world
13.
Why will the third line not work?
a)
Because num could be an integer, float or a string
b)
Because num will always be greater than count
c)
Because count doesn't add 1
d)
Because num will never be an integer
14.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
15.
How would you convert "hello" to lower case?
a)
"hello".lower()
b)
lower"hello"
c)
lower.("hello")
d)
("hello").lower
16.
What keyword is used to define a function? 
a)
def
b)
if
c)
while
d)
for
17.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
18.

What will the output be from the following code?

print(3+4)

a)

3+4

b)

7

c)

SyntaxError

d)

print(3+4)

19.
print("12"*3)
What would this print?
a)
36
b)
121212
c)
24
d)
12*3
20.

What will the output be from the following Python code?

print(Hello world!)

a)

Hello world!

b)

SyntaxError

c)

Hello world

d)

print(Hello world!)

21.

What is the Python built-in function to converts a number to a string?

a)

str()

b)

int()

c)

parseInt()

d)

convert

22.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
23.

The correct syntax for converting the string x to uppercase is :

a)

X.upper()

b)

upper(x)

c)

x.UPPER[ ]

d)

x.upper()

24.

The correct syntax for converting the string myname to lowercase is :

a)

myNAME.lower[ ]

b)

myname.lower( )

c)

myname.upper( )

d)

myname_lower(12 )

25.

Let x= "Python", the output of print(x.upper()) is

a)

python

b)

PYTHON

c)

_PYTHON

d)

"PYTHON"

26.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
27.
To create a variable named new_var and assign it a value of 81 divided by 9, which statement would you use?
a)
new_var = 81 \ 9
b)
new_var = "81 / 9"
c)
new_var = "81 \ 9"
d)
new_var = 81 / 9
28.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
29.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

30.

What is a piece of code that can take inputs to perform a certain task?

a)

a function

b)

arguments

c)

parameters

31.

Consider the line of code:

Football('Go Wildcats', 14, 21)

What is the Football?

a)

argument

b)

parameter

c)

function name

32.

Consider the line of code:

Football('Go Wildcats', 21, 14)

What is 'Go Wildcats' ?

a)

argument

b)

parameter

c)

function name

33.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

34.

Which of the following terms best describes the code above?

a)

function call

b)

function definition

35.

What is the name for the code highlighted in red?

a)

function name

b)

function definition

c)

parameters

d)

arguments

36.

Line 6 is called

a)

function definition

b)

function call

c)

function name

37.

What is a parameter in a function?

a)

input value to a function for the function’s execution

b)

a variable used to send information to a function

c)

the name of the function

d)

the name of the main program calling the function

38.

Choose the correct output of calling the function below with the call statement below:

def lowCase(words):

return words.lower()

myWords= lowCase("No CAPITAL letters")

print(myWords)

a)

no capital letters

b)

No CAPITAL letters

c)

name error

d)

No capital letters

39.

In the code snippet below, what is the output generated if the user enters 'Fortnite'?

game = input("enter a game")

print(game, "your score is", score)

score = 37856

a)

Fortnite your score is 37856

b)

SyntaxError

c)

NameError

d)

TypeError

40.

A function in Python can have ____ parameter(s).

a)

no

b)

as many as needed

c)

only 3

d)

only 1

41.

If a Python function is defined as below, which call(s) would be legal?

def library(book, price = 6.95):

other code as needed

a)

library( )

b)

library("Calculus book", 14.99)

c)

library("Accounting Book", 67, $6.95)

d)

library("Mad Magazine", 4.99, 10)

42.

Which of the following is true about the use of functions in Python?

a)

Functions don’t provide better modularity for your application

b)

You cannot create your own functions

c)

Functions are reusable pieces of programs

d)

All of the answers are true

43.

Which are the advantages of using functions in Python?

a)

Reducing duplication of code

b)

Decomposing complex problems

c)

Improving clarity of the code

d)

All options are true

44.

If a function doesn’t have a return statement, which of the following does the function return?

a)

int

b)

none

c)

null

d)

str

45.

What is the Python keyword used in EVERY function that the programmer creates.

a)

str

b)

int

c)

def

d)

num

46.

Order the below numbered code lines into the proper sequence so that the program will run without errors.


1. game = input("enter a game")

2. print(game, "your score is", score)

3. score = 199

a)

2,3,1

b)

3,2,1

c)

1,3,2

47.

A function with 2 float parameters could start with which definition?

a)

def 2Numbers(num1, num2):

b)

function addNumbers(num1, num2):

c)

def addNumbers(num1, num2):

48.

Which code below calls the function in the above code?

def tvShow():

print("Game of Thrones")

a)

tvShow()

b)

run.tvShow()

c)

showname()

d)

run tvshow

49.

Python Function return values must be stored in variables.

a)

True

b)

False

50.

Choose the correct output of calling the function below using the following code:

def addNum(num1 = 20):

return num1 + num1

print(addNum(100))

a)

TypeError

b)

NameError

c)

200

d)

50

51.

Which of the following items are present in the function header?

a)

Function name only

b)

Both function name and parameter list

c)

parameter list only

d)

Return value

52.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

53.

Line 6 is called

a)

function definition

b)

function call

c)

function name

54.

This code has an error. What's the problem?

a)

the parameters in the definition should have quotes since they're strings

b)

the number of arguments in the function call doesn't match the number of parameters in the function definition

c)

python doesn't allow more than one parameter in a function

d)

TJ isn't actually cool.

55.

4. The code block of function always comes after a _______.

a)

;

b)

:

c)

'

d)

#