Font size
WorksheetsPython {rogramming
Total questions: 45
Worksheet time: 29mins
Suppose you write a function. How many times can you call the function in your code?
Once
Not more than the number of commands the function holds
It depends on the function
As many times as you want
In which of the following situations would it be best to make a function?
You want Tracy to draw a blue line, and your program requires lots of blue lines.
You need Tracy to move forward by 100.
You need Tracy to turn right and then turn left.
You need to change Tracy’s color.
Which of the statements below is true about indentation in Python?
Indentation only matters in for loops. Then, everything must be indented one level.
Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read.
Indentation always matters in Python. Every statement must be aligned correctly.
Indentation only matters in functions. Then, everything must be indented one level.
Which of the following is NOT a purpose of using functions?
Functions let Tracy do new things.
Functions help group statements together to make your code more readable.
Functions let you execute code a fixed number of times.
Functions allow the programmer to reuse code.
What is the difference between defining and calling a function?
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.
There is no difference.
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.
Defining a function must be done each time you want to use the function. Calling a function can only happen once in your code.
Which of the following commands can be used to turn Tracy to face North if she is initially facing South?
left(90)
right(180)
left(180)
left(360)
What shape will be drawn with the following command?
circle(50, 360, 3)
(careful)
A circle
A hexagon
A triangle
A diamond
When the following for loop is complete, how many spaces will Tracy have moved?
for i in range(5):
forward(10)
50 spaces
60 spaces
10 spaces
5 spaces
name = 'Dave'
print (name)
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
Python is a _____________ side programming language.
client
server
west
east
What is the proper syntax for Python comments?
<!-- Python comment -->
<comment> Python comment <comment>
# Python Comment
/* Python Comment */
Which operator checks if a value is equal to another value?
+
=
==
!=
Which of these is true?
A syntax error will stop a program running
A logic error will stop a program running
A syntax error will let the program run but may have unexpected outcomes
The program will always show an error message for a logic error
If Tracy starts at the left edge of the canvas and moves forward 50 pixels, how many times will this code need to be repeated to have Tracy reach the right edge of the canvas?
4 times
8 times
12 times
16 times
Why do certain words change color in Python?
To show that they are recognized as key words.
To tell you that these words cannot be used in Python code.
To show you that these words can be clicked.
To tell Python to skip these words when running the code.
If I use the command right(180), which way will Tracy turn?
She will turn in a circle.
She will turn around.
She will turn to face up
She will turn to face left
If you wanted Tracy to complete her command immediately, which speed value would you use?
10
5
1
0
Tracy always starts facing which direction?
North
South
East
West
If Tracy started facing right, which direction would she be facing after we ran the following code?
left(90)
left(90)
right(90)
up
down
right
left
What are the dimensions of Tracy’s world?
100 x 100
200 x 200
200 x 400
400 x 400
In a guessing game, what will the following code snippet output if guess is '15' and number is 15?
Correct!
Incorrect!
Syntax Error
AttributeError
Which operator should be used in place of "?" to make the following expression evaluate to True? (5 ? 3) and (2 < 4)
>
<=
!=
==
In Python, what symbol is used to begin a comment?
//
/*
#
Match the vocabulary with the BEST example.
IDE
VSCode
Module
import random
Keyword
def
Method
random.randint()
Modulo
%
What is the output of the following code snippet?
97
96
86
15
14
What will be the value of total at the end of the program?
10
9
8
7
6
What is the output of the following program?
Grtings
GRTINGS
Greetings
GREETINGS
There is an error when the program is run.
How does Python interact with the hardware of a computer?
Directly interacts with the hardware
Uses an interpreter to translate high-level code into machine code
Uses a compiler to translate high-level code into machine code
Does not interact with the hardware at all
What does the abstraction in Python allow programmers to do?
Focus on writing hardware-specific code
Focus on writing code without dealing with hardware-specific details
Directly interact with the hardware
Create low-level machine code
What is the primary use of the print command in Python?
To accept user input.
To display output to the console.
To compile the code.
To create a graphical user interface.
Which of the following is true about the input() function in Python?
It is used to display output to the console.
It pauses the program and waits for the user to type something and press Enter.
It is used to compile the code.
It is used to create a graphical user interface.
Based on the following code, what gets printed to the screen?
greeting = 7
name = "Bob"
greeting = "Hello"
print(type(greeting))
What kind of data does an string contain?
Whole numbers
Letters, special characters, numbers, or words
Numbers with decimal components
True or False
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?
user_age
uSeRaGe
user!age!
1user_age
On which line of code will Python error?
Line 1
Line 2
Line 3
Line 4
What will the following program print when run?
Issue Driver’s License
Almost eligible for Driver’s License
No requirements met
Nothing will print
