wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Exam 2 (Intro to comp sci 4_30_20)

Total questions: 20

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

Which algorithm correctly expresses the following scenario?

If studentA has a minimum average of 80 and a SAT score of at least 950, they will be accepted into the university.

a)
b)
c)
d)
2.

Which choice below appropriately uses the '.format' command to produce the same output as the print statement on line 5 of this code?

a)
b)
c)
d)
3.

What is choice best explains the error that will be output in the IDLE when this code is executed?

a)

Name error: depositAmt not defined

b)

Syntax error: float not defined

c)

Type Error: can only concatenate str to str

d)

Type Error: can only concatenate float to float

4.

Which term most closely defines the word 'concatenate'?

a)

combine

b)

separate

c)

break down

d)

order

5.

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

a)

==

b)

=

c)

()

d)

*

6.

When you have an error in your code, what is the computer science term used to for finding and fixing that error?

a)

Error checking

b)

Debugging

c)

Syntax locating

d)

Error finder

7.

What would print ("10 + 16") produce?

a)

26

b)

"26"

c)

1016

d)

10 + 16

8.

What output would print ("8" + "11") produce?

a)

811

b)

19

c)

8 + 11

d)

"19"

9.

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

10.

What is the name of the environment in Python where write your programs and then test them out?

a)

Shell

b)

Window

c)

IDLE

d)

CLI

11.

What will be the output when this code is executed?

a)

You have deposited $500 and your final balance is $4000

4000

b)

Name error: balance is not defined

c)

4000

d)

Type error: can't concatenate str and int

12.
A _____________ expression is an expression that is either true or false. 
a)
boolean
b)
truth
c)
variable
d)
conditional
13.

Numbers with a decimal point belong to a datatype called...

a)

pointing

b)

integers

c)

decimal

d)

float

14.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
15.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
16.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
17.
Which of the following would lead to nothing being printed?
a)
age is 17 and birth_month is 8
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 10
d)
age is 12 and birth_month is 4
18.
Select the Python code that  displays 6 multiplied by 3
a)
6 ** 3
b)
6 / 3
c)
6 * 3
d)
6 % 3
19.
What Python command is used to request the user to enter data before the code continues to execute?
a)
variable
b)
str
c)
int
d)
input
20.

True or False:

A variable can hold only one value at a time.

a)

True

b)

False