wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS I--Final Exam

Total questions: 106

Worksheet time: 26hrs 16mins

Name
Class
Date
1.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
2.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
3.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
4.
What Python command lets the user enter an answer to a question?
a)
answer()
b)
open()
c)
print()
d)
input()
5.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
6.

Which of these will allow me to count from 0-20 in steps of 5?

a)

for x in range(0,20):

print(x)

b)

while x = (0,20,5):

print(x)

c)

for x in range(0,21,5):

print(x)

d)

for x in range(0,21,5):

print(y)

7.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
8.
What will print?
a)
1 2
b)
1
c)
3
d)
5
9.

Consider the line of code:

Label('Go Team', 200, 100)

What is the Label?

a)

argument

b)

parameter

c)

function name

10.

Consider the line of code:

Label('Go Team', 200, 100)

What is 'Go Team' ?

a)

argument

b)

parameter

c)

function name

11.

When defining a function, the definition must occur before it is called.

a)

true

b)

false

12.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

13.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

14.
What is printed when this program is run:
days = 5 
if days > 6:  
   print(“Month”)

else:  
   print(“Week”)
a)
Month
b)
Week
c)
Day
d)
4
15.

1.name = input("enter your name")

2. print(name, "your score is", score)

3. score = 199

Order the above numbered code lines into the proper sequence:

a)

3,1,2

b)

1,2,3

c)

1,3,2

d)

3,2,1

16.

answer = input("enter your answer: ")

print("You entered " + answer)


If user input is 38, what is the output of the above code?

a)

You entered 38

b)

TypeError

c)

SyntaxError

d)

You entered enter your answer

17.

In Python, we can use the "+" operator to add numbers, but not to add strings.

a)

True

b)

False

18.

1. PriNt("Hello World!") will not output the message "Hello World!".


What will it result in?

a)

NameError

b)

TypeError

c)

SyntaxError

d)

All of these

19.

What does the Python code: score = 3 + "45" result in?

a)

345

b)

type()

c)

TypeError

d)

48

20.

answer = input("enter your answer: ") print(10 + answer)


If user input is 38, what is the output of the above code?

a)

10answer

b)

TypeError

c)

1038

d)

48

21.

name = "Tobias"

print(name == "Alton")


What is the output from running the above code?

a)

"Tobias = Alton"

b)

False

c)

"Alton"

d)

True

22.

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

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

24.

Which term most closely defines the word 'concatenate'?

a)

combine

b)

separate

c)

break down

d)

order

25.

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

a)

26

b)

"26"

c)

1016

d)

10 + 16

26.

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

27.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
28.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
29.

1. The process of finding and removing errors.

a)

Debugging

b)

Syntax error

c)

Exception

30.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

31.

What result will display in the shell if 15 and 20 is entered by the user?

a)

"num1 + num2"

b)

1520

c)

35

32.

What datatype will the answer be if the user enters 15 and 30?

a)

Integer

b)

String

c)

Boolean

d)

Float

33.

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

34.

The modulo operator uses what symbol?

a)

**

b)

//

c)

%

d)

^

35.

x = True, y = False

What is the value of the expression not x?

a)

True

b)

False

36.

x = True, y = False

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

a)

True

b)

False

37.

The parameters could be a

a)

Variable

b)

Literal

c)

Expression

d)

Function

38.

Which of the following items are present in the function header?

a)

Function name only

b)

Both function name and parameter list

c)

parameter list only

d)

Return value

39.

What Is The Output Of The Following Code Snippet?


def func(message, num = 1):

print(message * num)


func('Welcome')

func('Viewers', 3)

a)

Welcome

Viewers

b)

Welcome

ViewersViewersViewers

c)

Welcome

Viewers,Viewers,Viewers

d)

Welcome

40.

Leo wants to create a function that will roll a dice. Which is the correct function definition header?

a)

def dice roll ():

b)

def diceroll ()

c)

def diceroll ():

d)

def diceroll []:

41.

What is the output of the given code?

a)

10 20 10

b)

10

c)

20

d)

10 20

42.

What is the output of the code

if 5 == 5

print("Hello")

else

print("Goodbye")

a)

Hello

b)

Goodbye

c)

error

d)

Hello

Goodbye

43.

What are the two main types of functions?

a)

Custom function

b)

Built-in function & User defined function

c)

User function

d)

System function

44.

Function calls should be placed at the beginning of a code page, and functions should be placed later and toward the end of the code.

a)

True

b)

False

45.

What will be the output of the following Python code?

a)

3

b)

4

c)

4 is maximum

d)

None of the mentioned

46.

What will be the output of the following Python code?

a)

x is 50

Changed local x to 2

x is now 50

b)

x is 50

Changed local x to 2

x is now 2

c)

x is 50

Changed local x to 2

x is now 100

d)

None of the mentioned

47.

What will be the output of the following Python code?

a)

Hello

WorldWorldWorldWorldWorld

b)

Hello

World 5

c)

Hello

World,World,World,World,World

d)

Hello

HelloHelloHelloHelloHello

48.

When using the circle() command, what value do we put inside the parentheses?

a)

The radius of the circle

b)

The center of the circle

c)

The diameter of the circle

d)

The width of the circle

49.

When Tracy is facing right, from what location does she start drawing her circle?

a)

The top of the circle

b)

The bottom of the circle

c)

The left side of the circle

d)

The middle of the circle

50.

What would be the output of the following command?

circle(50,360,5)

a)
b)
c)
d)
51.

What would be the output of the following command?

circle(50,180,3)

a)
b)
c)
d)
52.

What is missing from this input statement?

input ("What is your name? ")

a)

the answer

b)

a variable to store the input

c)

an output

d)

print =

53.

Look at the following code:

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

print (name)

What would be printed from the print command?

a)

whatever the user wrote

b)

name

c)

Andre

d)

What is your name?

54.

Look at the following code:

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

name = input ("What is your age? ")

print (name)


If the user answered "John" to the first question and "23" to the second, what will be printed?

a)

23

b)

John

c)

name

d)

an error message

55.

Look at the following code:

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

age = input ("What is your age? ")

print (name)


If the user answered "John" to the first question and "23" to the second, what will be printed?

a)

23

b)

John

c)

name

d)

an error message

56.

Look at the following code:

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

name = input ("What is your age? ")

print (age)


If the user answered "John" to the first question and "23" to the second, what will be printed?

a)

23

b)

John

c)

age

d)

an error message

57.

Look at the following code:

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

name = input ("What is your age? ")

print ("name")


If the user answered "John" to the first question and "23" to the second, what will be printed?

a)

23

b)

John

c)

name

d)

an error message

58.

Look at the following code:

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

name = input ("What is your age? ")


If the user answered "John" to the first question and "23" to the second, what type of data is in name?

a)

str

b)

int

c)

float

d)

none of the above

59.

How would you leave a trail that has a thickness of 25? No Spaces

(a)  

60.

How would you start leaving a trail that is the color red? No Spaces

(a)  

61.

How would you color in a shape with a color that you already selected? No Spaces

(a)  

62.

How would you stop filling in a shape that is a color you already selected? No Spaces.

(a)  

63.

How would I ask the question: "How old are you?" in my code? Only use spaces in the question.

(a)  

64.

What is the correct way to draw a circle that is filled in?

a)

begin_fill()

circle(20)

end_fill()

b)

circle(20)

begin_fill()

end_fill()

c)

circle(begin_fill, 20, end_fill)

d)

circle(20)

end_fill()

65.

The setposition() command moves Tracy to a coordinate and:

a)

turns her to face down

b)

turns her to face up

c)

turns her to face left

d)

does not turn her

66.

How would I collect a number from the user to use for the radius of a circle?

a)

int(input("What is the radius?: "))

b)

radius = int("What is the radius?: ")

c)

radius = int(input("What is the radius?: "))

d)

radius = int input("What is the radius?: ")

67.

Which of the following programs would produce this output?

a)

square_length = 20

for i in range(4):

forward(square_length)

left(90)

square_length = square_length * 2

b)

length=20

for i in range(4):

for i in range(4):

forward(length)

left(90)

length=length*2

68.

What will be the output of the code below?

penup()

backward(150)

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

forward(i * 2)

pendown()

circle(i)

penup()

a)

b)

c)

d)

69.

What code will draw 50 circles?

a)

for i in range(5):

circle(50)

forward(10)

b)

for i in range(50):

circle(50)

forward(10)

c)

do(50):

circle(50)

forward(10)

d)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

circle(50)

forward(10)

70.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
71.
To solve a problem that requires the user to enter 10 numbers would use what type of iteration?
a)
While loop
b)
For loop
c)
Variable
d)
Selection
72.
How would you assign an integer to a variable?
a)

new_var = 4

b)

new_var == 4

c)

new_var = "4"

d)

new var "4"

73.
To create a variable named new_var and assign it a value of 81 divided by 9, which statement would you use?
a)

new_var = 81 \ 9

b)

new_var = "81 / 9"

c)

new_var = "81 \ 9"

d)

new_var = 81 / 9

74.
Choose the statement that assigns 4 to the power of 3 to the variable new_var...
a)

new_var = 4 ** 3

b)

new_var = 3 ** 4

c)

new var = 3 ** 4

d)

new_var = 4 ^^ 3

75.
Which of the following is a float?
a)

new_var = 1234

b)

new_var = True

c)

new_var = 1.234

d)

new_var = "True"

76.
Which of the following is not a string?
a)

new_var = "True"

b)

new_var = "3123"

c)

new_var = "3.123"

d)

new_var = False

77.
Each time the body of a loop is executed, it is called a(n) _______________. 
a)
pass
b)
loopy
c)
iteration
d)
lap
78.

Which of the following sequences would be generated by the given line of code?

range (10, 0, -5)

a)

10,9,8,7,6,5

b)

10, 5

c)

0, 5, 10

d)

10, 5, 0

79.

In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?

for x in range (25, 10, -5)

a)

10

b)

-5

c)

25

d)

5

80.

What does symbol % do?

a)

Integer exact division

b)

Percentage

c)

Division

d)

Remainder

81.

Which of the operators do we use if we want at least one condition to be true?

a)

and

b)

or

c)

else

d)

not

82.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
83.

What will be the output of the following statement?

type('5')

a)

str

b)

int

c)

float

d)

Boolean

84.

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)

85.

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)

86.

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

87.

On which line of code will Python error?


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

88.
Which is the correct syntax?
a)
has_dog = true
b)
has_dog = True
c)
has_dog = Treu
d)
HAS_DOG = tRue
89.
What is the result of the code:
team = Cowboys
if team = Cowboys:
    print "Dallas is #1"
a)
Error
b)
Cowboys
c)
Team
d)
Dallas is #1
90.
Evaluate: (5 > 4) or (3 == 5)
a)
True
b)
False
91.

What will be printed on the screen when the following program is run?

a = not(5 > 4 and 10 >= 10)

print(a)

a)

True

b)

False

c)

Yes

d)

No

92.

What will be the output of this code? sum=?

a)

5

b)

15

c)

20

d)

25

93.

Which of these codes will print all the numbers from a given number subtracted by 5 until it reaches 0.

a)
b)
c)
d)
94.

Computer code made up of 0's and 1's is called:

a)

Python Code

b)

High Level Code

c)

Assembly Code

d)

Machine Code

95.

What does the following Python program print?

x = "Python"

y = "I love"

z = "programming"

print(y)

print(x)

print(z)

a)

Python I love programming

b)

I love

Python

Programming

c)

I lovePythonprogramming

d)

y

x

z

96.

What does the following Python program print?

x = 4 + 6 / 2 * 4 - 1

print(x)

a)

15

b)

19

c)

27

d)

None of the above

97.

What will the following code output:

print (23 % 5)

a)

3

b)

4

c)

18

d)

235

98.

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

99.

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

100.

What are the 3 boolean conditions we can use?

a)

for, but, and

b)

or, and, but

c)

and, or, not

d)

but, for, not

101.

Which of the following returns a random number between 1 and 10?

a)

randint(1,10)

b)

random.randint(1,10)

c)

random.randint(1,11)

d)

randint(1,11)

102.

How many times will this program print "hello"?

a)

0

b)

50

c)

100

d)

This code will loop infinitely

103.

How many times will this program print "hello"?

a)

0

b)

10

c)

i

104.

What is the output of the following code snippet? guess = '65.83' print(float(guess) + 1)

a)

66.83

b)

66

c)

65.84

d)

66.8

105.

Which operator should be used in place of "?" to make the following expression evaluate to True? (5 ? 3) and (2 < 4)

a)

>

b)

<=

c)

!=

d)

==

106.

How can you define a function `is_correct_guess` to accept two parameters, `guess` and `number`?

a)

def is_correct_guess[guess, number]:

b)

def is_correct_guess{guess, number}:

c)

def is_correct_guess(guess number):

d)

def is_correct_guess(guess, number):