WorksheetsSp25 Python Programming Final, Part 1
Total questions: 50
Worksheet time: 25mins
What does forward(100) do in Turtle Graphics?
Turns the turtle 100 degrees
Moves the turtle forward by 100 pixels
Sets the turtle’s speed
Draws a circle with radius 100
Which function is used to change the turtle's direction?
move()
turn()
left()
forward()
What happens if you use a negative value in forward(-50)?
Error
Moves backward
Turns 180 degrees
Clears the screen
Which command sets the turtle’s pen color?
color("blue")
setcolor("blue")
changecolor("blue")
color.pens("blue")
What does penup() do?
Lifts the turtle off the screen
Increases pen size
Stops the turtle from drawing lines
Moves the turtle faster
What symbol is used to make a comment in Python?
//
**
#
What does input() do?
Displays output on the screen
Pauses the program
Takes user input
Defines a function
What is the output of:
print("5" + "2")
7
52
What type of value does input() return?
Integer
Float
Boolean
String
Which function converts a string to an integer?
str()
toInt()
int()
number()
What keyword begins a conditional statement?
if
when
condition
check
Given the Python code shown, what will be printed?
Yes
No
10 > 5
Error
Which operator represents "not equal"?
!=
==
=
<>
What is the purpose of elif?
Ends the program
Declares a loop
Checks another condition
Comments code
Given the following Python code:
x = 3
print(x)
What will be printed?
3
x
None
Error
Which logical operator means “and”?
&&
and
&
also
What does this condition evaluate to?
5 > 3 and 2 > 4
True
False
Error
What type of loop is best for repeating something a set number of times?
while
repeat
for
until
How many times does this loop run?
4
5
6
Infinite
What is the output of the pictured code?
0 1 2
1 2 3
0 1 2 3
0 1 2 3 4
What keyword stops a loop early?
stop
skip
break
exit
What does continue do?
Ends the loop
Skips current iteration
Pauses the loop
Repeats previous iteration
What does
range(2, 10, 2)
return?
[2, 3, 4, 5, 6, 7, 8, 9]
[2, 4, 6, 8]
[2, 5, 8]
[2, 10, 2]
What kind of loop could result in an infinite loop if not careful?
for
while
both
neither
What keyword is used to define a function?
func
def
define
lambda
What is wrong with this function?
Missing colon
Wrong indent
Too many arguments
Wrong print syntax
How do you call a function named add()?
run add
call add
add()
What is the purpose of try and except?
Test values
Handle errors
Repeat loops
Define strings
What is printed?
5
6
8
double
Which part of this code runs when an error occurs?
try block
except block
finally block
error handling block
What does return do in a function?
Ends the function and sends a value
Loops again
Skips errors
Stops the program
What is the index of "o" in "hello"?
A) 1
B) 2
C) 3
D) 4
What does "Python".lower() return?
python
PYTHON
Python
error
What is the result of the following Python expression? "cat" + "dog"
catdog
cat dog
cat+dog
Error
Which method gets part of a string?
slice()
get()
sub()
indexing with [ ]
What does "hi"[1] return?
h
i
hi
Error
Which method removes spaces from both ends of a string?
trim()
strip()
split()
clean()
What data structure is created by [ ]?
Dictionary
String
List
Tuple
What does append() do to a list?
Removes items
Adds item to end
Sorts list
Reverses list
What does this print? Python numbers = [2, 4, 6] print(numbers[1])
2
4
6
1
Which method removes an item by index?
(a)
How do you create a dictionary?
()
[]
{}
<>
What will this print?
Python info = {"name": "Sam", "age": 16}
print(info["age"])
Sam
16
age
info
What is the index of the first item in a list?
1
0
-1
Depends
Which function gives the length of a list?
size()
count()
len()
range()
What does this code print?
Python fruits = ["apple", "banana"]
fruits[1] = "pear"
print(fruits)
A) ["apple", "banana"]
B) ["pear", "banana"]
C) ["apple", "pear"]
D) Error
What is a tuple?
A) A list that changes
B) A loop variable
C) A string
D) An immutable list
48. A tuple is defined as:
A mutable sequence of elements
An immutable sequence of elements
A collection of key-value pairs
A set of unique elements
Which structure uses key-value pairs?
List
Set
Dictionary
Tuple
What will this print?
Python colors = ("red", "green", "blue")
print(colors[2])
green
red
blue
Error
