Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Coding 1 Semester 1 review 2

Total questions: 25

Worksheet time: 15mins

Name
Class
Date
1.

What kind of data does an integer variable contain?

a)

Whole numbers

b)

Words

c)

Numbers that can have a decimal

d)

An integer is not a Python variable type

2.

Choose the correct declaration of a float variable named pi with the value 3.14

a)

pi = "3.14"

b)

pi = int(3.14)

c)

pi = 3.14

d)

float pi = 3.14

3.

Which of the following choices is a properly formed Python variable name, meaning it is both legal in the Python language and considered good style?

a)

FirstName

b)

first_name

c)

fIrStNAme

d)

!firstName

4.

The ability to use code again and again is called:

a)

Availability

b)

Reusability

c)

Abstraction

d)

Mobility

5.

What is the value of num after this code runs?

a)

0

b)

4

c)

5

d)

35

6.

Which one of the statements below will cause an error?

a)

ans = “hi” + 9

b)

ans = “hi” + “hi” + “hi"

c)

ans = 9 * (3 + 1) / 6

d)

ans = “yes”

7.

What is the output of the following function call?

a)

0

b)

4

c)

24

d)

48

8.

Which mode do you want to read and write to a file, but not erase what is already in the file?

a)

r

b)

r+

c)

w

d)

w+

9.

Where should the function definitions be in your code?

a)

At the top, after imports

b)

Anywhere, it doesn't matter

c)

Just before where it is called

d)

Just after where it is called

10.

What is the value returned by the following function?

a)

10

b)

35

c)

40

d)

50

11.

Which of the following choices is NOT a Python variable type?

a)

int

b)

str

c)

float

d)

number

12.

A function definition must start with:

a)

def

b)

int

c)

func

d)

function

13.

When a function sends something back to the main program, it uses a:

a)

assignment

b)

pass

c)

return

d)

transfer

14.

Choose the option that correctly prints out the variable(s).

a)

x = “hi”

print(int(x))

b)

num = 8

print(“num”)

c)

name = “Alyx”

age = 32

print(name + “ is “ + str(age))

d)

language = “Python”

print(“I’m learning “ language)

15.

Which line(s) of code will output 6 in the print statement?

a)

I and III

b)

I and IV

c)

II and III

d)

II and IV

16.

Given this code, what would be the correct line of code to call the function and receive the returned variables.

a)

nameAge(name, age)

b)

print(nameAge())

c)

name, age = nameAge()

d)

name = age = nameAge()

17.

What is the final result of the expression print(10 / 2 + 6)?

a)

11.0

b)

8.0

c)

0

d)

1.2

18.

On which line of code will Python error?

a)

Line 1

b)

Line 2

c)

Line 3

d)

Line 4

19.

Choose the print statement below that will cause an error. Assume that num=6, and name = "Isabella".

a)

print (name + “wants ” + “num ” + “candies”)

b)

print(name + “ wants ” + str(num) + “candies”)

c)

print (name + “ wants ” + num + “candies”)

20.

What is the output of this code:

a)

iday

b)

rida

c)

ida

d)

rid

21.

When a function returns a value, what must be done with the value?

a)

Assigned to a variable

b)

Printed (called from a print statement)

c)

Passed to another function

d)

Any of these

22.

The variables inside the parenthesis in a function definition are called

a)

Parameters

b)

Arguments

c)

Local variables

d)

Scope

23.

The order in which lines of code are executed is called

a)

Order of operations

b)

Line execution

c)

Flow of information

d)

Flow of execution

24.

Adding two strings together is called:

a)

Addition

b)

Concatenation

c)

Line printing

d)

Conversion

25.

What is the output of this code?

a)

Congratulations Bob, you are 15

b)

Congratulations 15, you are Bob

c)

No output because of an error