Font size
WorksheetsCS I--Final Exam
Total questions: 106
Worksheet time: 26hrs 16mins
Which of these will allow me to count from 0-20 in steps of 5?
for x in range(0,20):
print(x)
while x = (0,20,5):
print(x)
for x in range(0,21,5):
print(x)
for x in range(0,21,5):
print(y)
Consider the line of code:
Label('Go Team', 200, 100)
What is the Label?
argument
parameter
function name
Consider the line of code:
Label('Go Team', 200, 100)
What is 'Go Team' ?
argument
parameter
function name
When defining a function, the definition must occur before it is called.
true
false
A condition is
a statement that is either True or False
a string
an integer
a list
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
days = 5
if days > 6:
print(“Month”)
else:
print(“Week”)
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:
3,1,2
1,2,3
1,3,2
3,2,1
answer = input("enter your answer: ")
print("You entered " + answer)
If user input is 38, what is the output of the above code?
You entered 38
TypeError
SyntaxError
You entered enter your answer
In Python, we can use the "+" operator to add numbers, but not to add strings.
True
False
1. PriNt("Hello World!") will not output the message "Hello World!".
What will it result in?
NameError
TypeError
SyntaxError
All of these
What does the Python code: score = 3 + "45" result in?
345
type()
TypeError
48
answer = input("enter your answer: ") print(10 + answer)
If user input is 38, what is the output of the above code?
10answer
TypeError
1038
48
name = "Tobias"
print(name == "Alton")
What is the output from running the above code?
"Tobias = Alton"
False
"Alton"
True
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.
What is choice best explains the error that will be output in the IDLE when this code is executed?
Name error: depositAmt not defined
Syntax error: float not defined
Type Error: can only concatenate str to str
Type Error: can only concatenate float to float
Which term most closely defines the word 'concatenate'?
combine
separate
break down
order
What would print ("10 + 16") produce?
26
"26"
1016
10 + 16
What does the following code do?
myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
1. The process of finding and removing errors.
Debugging
Syntax error
Exception
What output will the console show, if 15 and 30 are entered by the user?
Syntax error
The sum of the two numbers - 45
The concatenation of the two numbers - 1530
Complier error
What result will display in the shell if 15 and 20 is entered by the user?
"num1 + num2"
1520
35
What datatype will the answer be if the user enters 15 and 30?
Integer
String
Boolean
Float
You have a variable named “True” and Python gives you an error. What’s the problem?
The “T” should be lower-case
“True” is a reserved keyword used by Python
Every letter must be capitalized
It’s correct. There is some other problem in the script
The modulo operator uses what symbol?
**
//
%
^
x = True, y = False
What is the value of the expression not x?
True
False
x = True, y = False
What is the value of the expression not x or not y?
True
False
The parameters could be a
Variable
Literal
Expression
Function
Which of the following items are present in the function header?
Function name only
Both function name and parameter list
parameter list only
Return value
What Is The Output Of The Following Code Snippet?
def func(message, num = 1):
print(message * num)
func('Welcome')
func('Viewers', 3)
Welcome
Viewers
Welcome
ViewersViewersViewers
Welcome
Viewers,Viewers,Viewers
Welcome
Leo wants to create a function that will roll a dice. Which is the correct function definition header?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What is the output of the given code?
10 20 10
10
20
10 20
What is the output of the code
if 5 == 5
print("Hello")
else
print("Goodbye")
Hello
Goodbye
error
Hello
Goodbye
What are the two main types of functions?
Custom function
Built-in function & User defined function
User function
System function
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.
True
False
What will be the output of the following Python code?
3
4
4 is maximum
None of the mentioned
What will be the output of the following Python code?
x is 50
Changed local x to 2
x is now 50
x is 50
Changed local x to 2
x is now 2
x is 50
Changed local x to 2
x is now 100
None of the mentioned
What will be the output of the following Python code?
Hello
WorldWorldWorldWorldWorld
Hello
World 5
Hello
World,World,World,World,World
Hello
HelloHelloHelloHelloHello
When using the circle() command, what value do we put inside the parentheses?
The radius of the circle
The center of the circle
The diameter of the circle
The width of the circle
When Tracy is facing right, from what location does she start drawing her circle?
The top of the circle
The bottom of the circle
The left side of the circle
The middle of the circle
What would be the output of the following command?
circle(50,360,5)
What would be the output of the following command?
circle(50,180,3)
What is missing from this input statement?
input ("What is your name? ")
the answer
a variable to store the input
an output
print =
Look at the following code:
name = input ("What is your name? ")
print (name)
What would be printed from the print command?
whatever the user wrote
name
Andre
What is your name?
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?
23
John
name
an error message
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?
23
John
name
an error message
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?
23
John
age
an error message
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?
23
John
name
an error message
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?
str
int
float
none of the above
How would you leave a trail that has a thickness of 25? No Spaces
(a)
How would you start leaving a trail that is the color red? No Spaces
(a)
How would you color in a shape with a color that you already selected? No Spaces
(a)
How would you stop filling in a shape that is a color you already selected? No Spaces.
(a)
How would I ask the question: "How old are you?" in my code? Only use spaces in the question.
(a)
What is the correct way to draw a circle that is filled in?
begin_fill()
circle(20)
end_fill()
circle(20)
begin_fill()
end_fill()
circle(begin_fill, 20, end_fill)
circle(20)
end_fill()
The setposition() command moves Tracy to a coordinate and:
turns her to face down
turns her to face up
turns her to face left
does not turn her
How would I collect a number from the user to use for the radius of a circle?
int(input("What is the radius?: "))
radius = int("What is the radius?: ")
radius = int(input("What is the radius?: "))
radius = int input("What is the radius?: ")
Which of the following programs would produce this output?
square_length = 20
for i in range(4):
forward(square_length)
left(90)
square_length = square_length * 2
length=20
for i in range(4):
for i in range(4):
forward(length)
left(90)
length=length*2
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()
What code will draw 50 circles?
for i in range(5):
circle(50)
forward(10)
for i in range(50):
circle(50)
forward(10)
do(50):
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)
circle(50)
forward(10)
new_var = 4
new_var == 4
new_var = "4"
new var "4"
new_var = 81 \ 9
new_var = "81 / 9"
new_var = "81 \ 9"
new_var = 81 / 9
new_var = 4 ** 3
new_var = 3 ** 4
new var = 3 ** 4
new_var = 4 ^^ 3
new_var = 1234
new_var = True
new_var = 1.234
new_var = "True"
new_var = "True"
new_var = "3123"
new_var = "3.123"
new_var = False
Which of the following sequences would be generated by the given line of code?
range (10, 0, -5)
10,9,8,7,6,5
10, 5
0, 5, 10
10, 5, 0
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)
10
-5
25
5
What does symbol % do?
Integer exact division
Percentage
Division
Remainder
Which of the operators do we use if we want at least one condition to be true?
and
or
else
not
print(Hello world!)
What will be the output of the following statement?
type('5')
str
int
float
Boolean
Choose the print statement below that will cause an error. Assume that num has the value 6, and name has the value Isabella.
print(name + “:” )
print(num)
print(name + ” wants ” + “num ” + “candies”)
print(name + “: ” + str(num))
print(name + “: ” + num)
Choose the option that correctly prints out the variable(s).
x = "codehs"
print(int(x))
num = 8
print("num")
name = "Alyx"
age = 32
print(name + "is " + age)
language = "Python"
print("I'm learning " + language)
What does the following code print?
x = 3.4
y = 1
print(int(x))
print(x + y)
3.4
4.4
3
4.4
3
4
The code causes an error
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)
Line 1
Line 2
Line 3
Line 4
team = Cowboys
if team = Cowboys:
print "Dallas is #1"
What will be printed on the screen when the following program is run?
a = not(5 > 4 and 10 >= 10)
print(a)
True
False
Yes
No
What will be the output of this code? sum=?
5
15
20
25
Which of these codes will print all the numbers from a given number subtracted by 5 until it reaches 0.
Computer code made up of 0's and 1's is called:
Python Code
High Level Code
Assembly Code
Machine Code
What does the following Python program print?
x = "Python"
y = "I love"
z = "programming"
print(y)
print(x)
print(z)
Python I love programming
I love
Python
Programming
I lovePythonprogramming
y
x
z
What does the following Python program print?
x = 4 + 6 / 2 * 4 - 1
print(x)
15
19
27
None of the above
What will the following code output:
print (23 % 5)
3
4
18
235
What will print to the screen when the following program is run?
number = 5
less_than_zero = number < 0
print(type(less_than_zero))
5
False
<type ‘int’>
<type ‘bool’>
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)
1
1
3
5
1
4
1
4
5
What are the 3 boolean conditions we can use?
for, but, and
or, and, but
and, or, not
but, for, not
Which of the following returns a random number between 1 and 10?
randint(1,10)
random.randint(1,10)
random.randint(1,11)
randint(1,11)
How many times will this program print "hello"?
0
50
100
This code will loop infinitely
How many times will this program print "hello"?
0
10
i
What is the output of the following code snippet? guess = '65.83' print(float(guess) + 1)
66.83
66
65.84
66.8
Which operator should be used in place of "?" to make the following expression evaluate to True? (5 ? 3) and (2 < 4)
>
<=
!=
==
How can you define a function `is_correct_guess` to accept two parameters, `guess` and `number`?
def is_correct_guess[guess, number]:
def is_correct_guess{guess, number}:
def is_correct_guess(guess number):
def is_correct_guess(guess, number):
