Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Part 1 Final Tech Exam

Total questions: 60

Worksheet time: 15hrs 0mins

Name
Class
Date
1.

When the following for loop is complete, how many spaces will Tracy have moved?

for i in range(5):

forward(10)

a)

50 spaces

b)

60 spaces

c)

10 spaces

d)

5 spaces

2.

Suppose you write a function. How many times can you call the function in your code?

a)

Once

b)

Not more than the number of commands the function holds

c)

It depends on the function

d)

As many times as you want

3.

In which of the following situations would it be best to make a function?

a)

You want Tracy to draw a blue line, and your program requires lots of blue lines.

b)

You need Tracy to move forward by 100.

c)

You need Tracy to turn right and then turn left.

d)

You need to change Tracy’s color.

4.

Which of the following pieces of code will make Tracy do the following actions three times: go forward, change colors, and then turn around.

a)

for i in range(4):

forward(30)

color("blue")

left(180)

b)

for i in range(3):

forward(30)

color("blue")

left(180)

color("red")

c)

for i in range(3):

backward(30)

color("blue")

left(180)

d)

forward(30)

color("blue")

left(180)


forward(30)

color("green")

left(180)


forward(30)

color("orange")

left(180)

5.

Suppose you want to make Tracy draw a mountain range, like the one shown below, starting from the left side.


Which of the following functions would be the most useful function to write in order to solve this problem?

a)

# Has Tracy draw a single triangle

def make_triangle():

b)

# Change's Tracy's color to red

def change_to_red()

c)

# Moves Tracy forward by 100

def move_100():

d)

# Draws a square

def my_function():

6.

Which of the following is NOT a command you can give to Tracy?

a)

color

b)

turn

c)

backward

d)

left

7.

Which of the statements below is true about indentation in Python?

a)

Indentation only matters in for loops. Then, everything must be indented one level.

b)

Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read.

c)

Indentation always matters in Python. Every statement must be aligned correctly.

d)

Indentation only matters in functions. Then, everything must be indented one level.Answered Indentation only matters in functions. Then, everything must be indented one level.

8.

Which of the following statements are true about for loops?

A. By default, the range function starts at 0

B. Using for i in range(4) will result in i taking the values 0, 1, 2, 3, 4

C. For loops let you repeat something any number of times

D. Statements in a for loop do not need to be indented

E. It is not possible to have the range values count 6, 12, 18, 24

F. It is not possible to have the range values count 1, 2, 4, 8, 16

a)

A, C, and F

b)

A, B, C, and F

c)

A, B, C, E, and F

d)

A and C

9.

Which of the following functions is defined correctly?

a)

def draw_edge():

forward(100)

left(90)

b)

def draw_edge()

forward(100)

left(90)

c)

def draw_edge

forward(100)

left(90)

d)

def draw_edge(){

forward(100)

left(90)

}

10.

Which of the following is NOT a purpose of using functions?

a)

Functions let Tracy do new things.

b)

Functions help group statements together to make your code more readable.

c)

Functions let you execute code a fixed number of times.

d)

Functions allow the programmer to reuse code.

11.

What is the difference between defining and calling a function?

a)

Defining a function means you are teaching the computer a new word. Calling a function means you are commanding the computer to complete defined actions.

b)

There is no difference.

c)

Calling a function means you are teaching the computer a new word. Defining a function means you are commanding the computer to complete defined actions.

d)

Defining a function must be done each time you want to use the function. Calling a function can only happen once in your code.

12.

What does the number in the parentheses in a forward or backward command represent?

a)

How many degrees Tracy is supposed to turn

b)

How fast Tracy is supposed to move

c)

How many times Tracy should repeat the command

d)

How far Tracy is supposed to move

13.

What control structure would be best to use in the following code?

backward(100)

right(90)

backward(100)

right(90)

backward(100)

right(90)

backward(100)

right(90)

a)

A function

b)

A while loop

c)

A for loop

d)

An if/else statement

14.

Which of the following commands can be used to turn Tracy to face North if she is initially facing South?

a)

left(90)

right(90)

b)

right(180)

c)

right(90)

left(180)

d)

right(90)

left(180)

15.

Which program below includes no errors?

a)

#

Draw a square

#

for i in range(4):

left(90)

forward(40)

b)

# Draw a square

def draw square:

for i in range(4):

left(90)

forward(90

c)

# Draw a square

for i in range(4):

left(90)

forward(90)

d)

# Draw a square

def draw square():

for i in range(4):

left(90)

forward(90)

16.

Which of the following commands can NOT be used to draw one square?

a)

forward(50)

left(90)

forward(50)

left(90)

forward(50)

left(90)

forward(50)

left(90)

b)

for i in range(4):

forward(50)

left(90)

c)

circle(50, 360, 4)

d)

for i in range(4):

circle(50, 360, 4)

17.

What shape will be drawn with the following command?circle(50, 360, 3)

a)

A circle

b)

A hexagon

c)

A triangle

d)

A diamond

18.

How can we use variable to control the size of a circle?

a)

radius = 50

circle(radius)

b)

radius = circle(50)

c)

circle(radius)

radius = 50

d)

radius = 50

circle(50)

19.

Can a user’s input control the size of a circle? If so, how?

a)

No, user input is a string.

b)

Yes

circle(user_input=50)

c)

Yes

radius = int(input("Radius: "))

circle(radius)

d)

Yes

radius = input("Radius: ")


circle(radius)

20.

What is the most effective way to draw three circles in a row of different colors?

a)

for i in range(3):

circle(50)

penup()

forward(100)

pendown()

color("red")

b)

def draw_circle(color_choice):

pendown()

begin_fill()

circle(50)

end_fill()

penup()

forward(50)

color("red")

draw_circle()

color("blue")

draw_circle()

color("yellow")

draw_circle()

c)

def draw_circle(color_choice):

pendown()

color(color_choice)

begin_fill()

circle(50)

end_fill()

penup()

forward(100)

draw_circle("red")

draw_circle("blue")

draw_circle("yellow")

d)

def draw_circle(color_choice):

pendown()

color(color_choice)

begin_fill()

circle(50)

end_fill()

penup()

forward(50)

draw_circle("red")

draw_circle("blue")

draw_circle("yellow")

21.

What will be the output of the following program?

for i in range(3, 7, 2):

circle(50, 360, i)

a)

Three circles with radii of 3, 7 and 2.

b)

Three shapes- a triangle (3 sides), a heptagon (7 sides), and a line (2 sides).

c)

Three shapes- a triangle (3 sides), a pentagon (5 sides), and a heptagon (7 sides).

d)

Two shapes- a triangle (3 sides) and a pentagon (5 sides).

22.

What will be the radii of the circles drawn from the following code?

for i in range(10, 55, 10):

circle(i)

a)

10, 20, 30, 40, 50

b)

10, 15, 20, 25, 30, 35, 40, 45, 50, 55

c)

10, 55, 10

d)

10, 20, 30, 40, 50, 55

23.

Which command will Tracy perform when given the following code?

count = 200

count = count + 1

if count % 2 == 0:

forward(count)

backward(count)

a)

forward(200)

b)

backward(200)

c)

forward(201)

d)

backward(201)

24.

Which command will Tracy perform when given the following code?

count = 5

count = count * 2

if count < 10:

forward(count)

elif count < 20:

backward(count)

else:

circle(count)

a)

forward(10)

b)

backward(10)

c)

backward(10)

circle(10)

d)

circle(10)

25.

What will be the output of the following code?

count = 5

while count > 0:

circle(50)

forward(100

a)

5 circles in a row

b)

4 circles in a row

c)

A slinky with 5 circles

d)

An infinite loop will occur

26.

What is the final result of the expression 4 + 5 * 3?

a)

27

b)

12

c)

21

d)

19

27.

What is the final result of the expression 7 / 2 + 6?

a)

0

b)

9.5

c)

9

d)

0.875

28.

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

a)

print(name + ":" )

print(num)

b)

print(name + " wants " + "num " + "candies")

c)

print(name + ": " + str(num))

d)

print(name + ": " + num)

29.

Which one of the statements below will cause an error?

a)

ans = “hi” * 8

b)

ans = “hi” + 9

c)

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

d)

ans = (“a” * 4) + “b” ans = (“a” * 4) + “b”

30.

What does the following program print?

a = "hi"

b = 4

c = a * b

print(type(c))

a)

<type 'str'>

b)

<type 'int'>

c)

<type 'float'>

d)

The program crashes and doesn’t print anything.

31.

The program crashes and doesn’t print anything.

a)

str

b)

int

c)

float

d)

number number

32.

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

a)

x = "codehs"

print(int(x))

b)

num = 8

print("num")

c)

name = "Alyx"

age = 32

print(name + "is " + age)

d)

language = "Python"

print("I'm learning " + language)

33.

What kind of data does a float variable contain?

a)

Whole numbers

b)

Words

c)

Numbers that can have decimal components

d)

A float is not a Python variable type A float is not a Python variable type

34.

What does the following code print?

x = 3.4

y = 1

print(int(x))

print(x + y)

a)

3.4

4.4

b)

3

4.4

c)

3

4

d)

The code causes an error

35.

Which of the following options is the best way to get a number from the user that you plan to use in a mathematical equation?

a)

num = str(input(“Enter a number: “))

b)

num = number(input(“Enter a number: “))

c)

num = input(“Enter a number: “)

d)

num = int(input(“Enter a number: “))

36.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

That is not a valid Python expression.

37.

What is the character that in-line Python comments begin with?

a)

#

b)

%

c)

-

d)

"

38.

What is the difference between a binary operator and a unary operator?

a)

A computer can use binary operators, but it cannot use unary operators.

b)

A unary operator needs two things, while a binary operator only needs one.

c)

A binary operator needs two things, while a unary operator only needs one.

d)

Binary operators are used for arithmetic expressions, while unary operators are for strings.

39.

weight = input("How much do you weigh? ")

oz_water = weight / 2

print("You should drink " + str(oz_water))

print("ounces of water every day if you weigh " + weight)

a)

Line 1

b)

Line 2

c)

Line 3

d)

Line 4

40.

In what order should these statements be executed in order to get input from the user and print out the result?

A) response = input("Do you like cheese? ")

B) print("You have chosen " + confirm)

C) print("You responded " + response)

D) confirm = input("Are you sure? ")

a)

A, B, C, D

b)

B, C, A, D

c)

A, C, D, B

d)

C, B, A, D

41.

What is the output of the following program? Assume the user enters “Florence”, then “Fernandez”.

first_name = input("What is your first name? ")

last_name = input("What is your last name? ")

whole_name = first_name + last_name

print(whole_name)

a)

Fernandez Florence

b)

Florence

Fernandez

c)

FlorenceFernandez

d)

Florence Fernandez

42.

Which of the following statements is true about print statements?

I. In order to print a string literal, the string must be enclosed in quotes.

II. Each print statement will be printed on its own line.

III. Print statements will not let you print string and number characters in the same statement.

IV. Print statements are how you display text on the screen.

a)

I, IV

b)

II, III

c)

I, II, IV

d)

I, III, IV

43.

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)

user_age

b)

uSeRaGe

c)

user!age!

d)

1user_age

44.

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

a)

int

b)

str

c)

float

d)

number

45.

Choose the correct declaration of a float variable with the value 3.14.

a)

pi = “3.14”

b)

pi = int(3.14)

c)

pi = 3.14

d)

float pi = 3.14

46.

What does this program print?

favorite_color = "blue"


if favorite_color != "blue":

if favorite_color != "red":

print("Must be yellow")

elif favorite_color == "blue":

if favorite_color != "yellow":

print("Must be blue")

elif favorite_color == "blue":

if favorite_color != "yellow":

print("I like purple")

else:

if favorite_color == "blue":

print("Blue is the best")

a)

Must be yellow

b)

Must be blue

I like purple

Blue is the best

c)

Must be blue

d)

Blue is the best

47.

How would you round the number held in the variable pi to 3.14?

pi = 3.14159265

a)

round(pi)

b)

round(pi, 3)

c)

round(3, pi)

d)

round(pi, 2)

48.

Why should you use round when you compare two numbers that have type float?

a)

If you don’t, Python will only compare the whole part and discard the decimal part.

b)

You don’t have to, but it’s good style. All of the comparisons will still work out the same way.

c)

Sometimes numbers can be rounded in unexpected ways based on how Python computes them. Therefore, it is best to use round in order to make sure both numbers are rounded the same way.

d)

You should always use round when you compare two numbers, even if they are of type int.

49.

What will print to the screen when the following program is run?

number = 5

greater_than_zero = number > 0

print(type(number))

a)

5

b)

True

c)

<type ‘int’>

d)

<type ‘bool’>

50.

What will print to the screen when the following program is run?

number = 5

less_than_zero = number < 0

print(type(less_than_zero))

a)

5

b)

False

c)

<type ‘int’>

d)

<type ‘bool’>

51.

What will be the output of this program?

number = 5

greater_than_zero = number > 0


if greater_than_zero:

print(number)

a)

0

b)

5

c)

True

d)

Nothing will print

52.

What will be the output of this program?

number = 5

greater_than_zero = number > 0


if greater_than_zero:

if number > 5:

print(number)

a)

0

b)

5

c)

True

d)

Nothing will print

53.

What will be the output of this program?

number = 5

less_than_zero = number < 0


if less_than_zero:

print(number)


number = number-10

less_than_zero = number < 0


if less_than_zero:

print(number)

a)

5

5

b)

-5

c)

5

-5

d)

Nothing will print

54.

What will be the output of this program?

number = 5

greater_than_zero = number > 0

less_than_zero = number < 0


if greater_than_zero:

print(number)

if less_than_zero:

print(number + 1)

if greater_than_zero and less_than_zero:

print(number + 2)

if greater_than_zero or less_than_zero:

print(number + 3)

a)

5

b)

5

7

c)

5

7

8

d)

5

8

55.

What will the following program print when run?

above_16 = True

has_permit = True

passed_test = False


if above_16 and has_permit and passed_test:

print("Issue Driver's License")

elif above_16 or has_permit or passed_test:

print("Almost eligible for Driver's License")

else:

print("No requirements met.")

a)

Issue Driver’s License

b)

Almost eligible for Driver’s License

c)

No requirements met

d)

Nothing will print

56.

What will the following program print when run?

number_one = 5

number_two = 10


if number_one == 5:

print(1)

if number_one > 5:

print(2)

if number_two < 5:

print(3)

if number_one < number_two:

print(4)

if number_one != number_two:

print(5)

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

57.

What will the following program print when run?

number_one = 5

number_two = 10


if number_one == 5:

print(1)

elif number_one > 5:

print(2)

elif number_two < 5:

print(3)

elif number_one < number_two:

print(4)

elif number_one != number_two:

print(5)

else:

print(6)

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

58.

What does this program print?

height = 65

gender = "female"


if height < 62:

print("You are below average height")

elif height > 69:

print("You are above average height")

else:

print("You are average height")

a)

You are below average height

b)

You are above average height

c)

You are average height

d)

You are below average height

You are above average height

59.

What does this program print?

height = 65

gender = "female"


if height < 62 or (height < 69 and gender == "male"):

print("You are below average height")

elif height > 69 or (height > 62 and gender == "female"):

print("You are above average height")

else:

print("You are average height")

a)

You are below average height

b)

You are above average height

c)

You are average height

d)

You are below average height

You are above average height

60.

What does this program print?

favorite_color = "blue"


if favorite_color != "green":

print("But green is the color of grass!")

if favorite_color == "red":

print("I like red, too!")

if favorite_color == "blue":

print("Blue is the best")

if favorite_color != "yellow":

print("But yellow is the color of school buses!")

a)

But green is the color of grass!

Blue is the best

But yellow is the color of school buses!

b)

But green is the color of grass!

c)

But green is the color of grass!

I like red, too!

Blue is the best

But yellow is the color of school buses!

d)

Blue is the best