wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Semester 2 Exam Review

Total questions: 52

Worksheet time: 28mins

Name
Class
Date
1.

You have a variable named “True” and Python gives you an error. What’s the problem?

a)

The “T” should be lower-case

b)

“True” is a reserved keyword used by Python

c)

Every letter must be capitalized

d)

It’s correct. There is some other problem in the script

2.

The modulo operator uses what symbol?

a)

**

b)

//

c)

%

d)

^

3.

Python comments are denoted by what symbol?

a)

#

b)

//

c)

/*

d)

$

4.

x = True, y = False

What is the value of the expression not x?

a)

True

b)

False

5.

x = True, y = False

What is the value of the expression y and not x?

a)

True

b)

False

6.

x = True, y = False

What is the value of the expression not x or not y?

a)

True

b)

False

7.

What common Python function is used to display text to the screen?

a)

display

b)

output

c)

print

d)

show

8.

The (a)   data type represents true or false.

9.

Strings are a collection of (a)   , such as letters, numbers, or symbols.

10.

True/False: Code blocks are always indented.

(a)  

11.

True/False: Else statements do not require an if statement before it.

(a)  

12.

True/False: Strings are immutable, which means that they can change.

(a)  

13.

True/False: A for loop runs for a certain number of times.

(a)  

14.

Observe the following code segment:

num = 4

if num <= 4 and num + 1 != 5:

print("A")

elif num < 4:

print("B")

print("C")

What is the final output?

a)

C

b)

B

c)

A

d)

AB

e)

AC

15.

When using format on a string, which of the following represents a placeholder for a value?

a)

{ }

b)

[ ]

c)

( )

d)

< >

16.

In Python, what do we use to start a code block?

a)

colon

b)

quotes

c)

forward slash

d)

question marks

17.

A Code Block is: (Choose all that apply)

a)

A collection of lines of codes

b)

Always indented

c)

Never indented

d)

Allowed to be typed how the programmer feels works best

18.

What allows code to go down different paths based on Boolean expressions?

a)

Conditional statement

b)

False statement

c)

True statement

d)

Factual statement

19.

What has to happen for an else statement to work properly? (Choose Two)

a)

It has to have an if statement before it.

b)

the condition has to fail.

c)

the condition has to be true.

d)

it takes the place of an if statement.

20.

An if statement checks if something is:

a)

true

b)

false

21.

How many if statements can we put into a code, as long as we are entering them properly?

a)

As many as you want

b)

3

c)

5

d)

1

22.

What does elif mean?

(a)  

23.

What best describes an input?

a)

A pause in the function until the user types in something and hits enter.

b)

A section of the program that prints a value.

c)

A pause in the program until the computations are completed.

d)

An area of code that requires the program itself to enter something and hit enter.

24.

Format function allows us to format:

a)

Strings

b)

Integers

c)

Variables

d)

Parameters

25.

An input function will only return what as a variable?

a)

String

b)

Boolean

c)

Float

d)

Integer

26.

What function will show zero or more things that are separated by a comma?

a)

Print

b)

Function

c)

Show

d)

Variable

27.

What do we need to use to show that something is a parameter?

a)

colon

b)

comma

c)

parenthesis

d)

quotes

28.

Which operator means power:

a)

+

b)

-

c)

*

d)

//

e)

**

29.

x=True, y=False

What is the value of the expression: not x

a)

True

b)

False

30.

x=True, y=False

What is the value of the expression: x or y

a)

True

b)

False

31.

Which comparison Operator means not equal to:

a)

!=

b)

=!

c)

==

d)

=/=

32.

What is the main purpose for using Assignment Operators?

a)

Shorthand for longer expressions

b)

Simple Assignment

c)

Assigning a value to the variable

d)

SO MUCH MATH

33.

In Python, there are four groups of operators:

a)

Calculations

b)

Comparison

c)

Assignment

d)

Logical

e)

Answers

34.

A while loop will keep running as long as something is:

a)

True

b)

False

35.

A (a)   is a name that refers to a value.

36.

Reserved words, known as keywords, cannot be used for variable names.

a)

True

b)

False

37.

True/False: Function names can start with a digit.

(a)  

38.

True/False: Function parameters affect a variables value after the function is complete.

(a)  

39.

Given the following function:

def square_number( x ):

return x * x

What does the function call square_number(2+4) return?

a)

4

b)

8

c)

16

d)

36

40.

Consider the following code segment:

x = 7.4

int( x )

print( x )

What is the value of x at the end of this code?

a)

7.4

b)

7

c)

74

d)

7.0

41.

You are creating a function that manipulates floating point values. You have two requirements: the function must take the absolute value of the float, and the value must be rounded up to the nearest integer value. Which two math functions should you use to accomplish this task?

a)

math.abs(x)

b)

math.ceil(x)

c)

math.exp(x)

d)

math.floor(x)

e)

math.mod(x)

42.

Given the following function:

def divide_by_ten( number):

while number / 10 >= 10:

number /= 10

return number

What would the function call divide_by_ten(480) return?

a)

480

b)

80

c)

48

d)

4

43.

What do we call a block of code that performs an action?

a)

Ability

b)

Format

c)

Function

d)

Variable

44.

True/False: Functions can be reused to simplify our programs and prevent us from repeating ourselves.

(a)  

45.

What are the elements that make up a function? (Choose all that apply)

a)

Name

b)

Parameters

c)

Return

d)

Value

e)

Format

46.

Some functions have ____ which are values supplied to the function to work.

a)

Parameters

b)

Parenthesis

c)

Strings

d)

Variables

47.

Name the keyword used to define a function.

a)

define

b)

def

c)

function

d)

fu

48.

Which one is not true about function?

a)

It breaks the large program into small modules.

b)

It avoids repetition.

c)

It makes code reusable.

d)

It makes the program unorganized.

49.

You have a function called classes_schedule that returns the class name, period, time of your current schedule. Which of the following statements will return all three of these values?

a)

return science, 1st period, 7:25

b)

return class name & period & time

c)

return class name, period, time

d)

class name + period + time

e)

You cannot return multiple values

50.

Given the following function:

def divide_by_ten( number):

while number / 10 >= 10:

number /= 10

return number

What would the function call divide_by_ten(360) return?

a)

360

b)

36

c)

300

d)

8

51.

You are creating a function that manipulates floating point values.

What functions would I use to get the value of the nearest integer value?

Which two math functions should you use to accomplish this task?

a)

math.abs(x)

b)

math.exp(x)

c)

math.mod(x)

d)

math.ceil(x)

e)

math.floor(x)

52.

Which words cannot be used for variable names? (select all that apply)

a)

Reserved

b)

Keywords

c)

Saved words

d)

Any string