wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Science Essentials Semester Exam 2021

Total questions: 60

Worksheet time: 15hrs 0mins

Name
Class
Date
1.

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)
b)
c)
d)
5.

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.

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)
b)
c)
d)
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.
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)

left(360)

15.

Which program below includes no errors?

a)
b)
c)
d)
16.

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

a)
b)
c)
d)
17.

What shape will be drawn with the following command?

circle(50, 360, 3)

a)

circle

b)

hexagon

c)

triangle

d)

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)
b)
c)
d)
21.
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.

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.

Remember % is the remainder operator.

a)

forward(200)

b)

backward(200)

c)

forward(201)

d)

backward(201)

24.
a)

forward(10)

b)

backward(10)

c)

backward(10)

circle(10)

d)

circle(10)

25.

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?


**remember your order of operations

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”

30.
a)

<type 'str'>

b)

<type 'int'>

c)

<type 'float'>

d)

The program crashes and doesn’t print anything.

31.

Suppose you have a variable defined a = "4". What is the variable type of a?

a)

str

b)

int

c)

float

d)

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

34.
a)

3.4

4.4

b)

3

4.4

c)

3

4

d)

This 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)

This is not a valid Python operation.

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.
a)

Line 1

b)

Line 2

c)

Line 3

d)

Line 4

40.

a)

A, B, C, D

b)

B, C, A, D

c)

A, C, D, B

d)

C, B, A, D

41.

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.
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.

a)

5

b)

True

c)

<type ‘int’>

d)

<type ‘bool’>

50.

a)

5

b)

True

c)

<type ‘int’>

d)

<type ‘bool’>

51.

a)

0

b)

5

c)

True

d)

Nothing will print

52.

a)

0

b)

5

c)

True

d)

Nothing will print

53.

a)

5

5

b)

-5

c)

5

-5

d)

Nothing will print

54.

a)

5

b)

5

7

c)

5

7

8

d)

5

8

55.

a)

Issue Driver’s License

b)

Almost eligible for Driver’s License

c)

No requirements met

d)

Nothing will print

56.

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

57.

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

58.

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.

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.

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