What is a function?
A function is a way to group a set of commands so they can be called with one line of code
How do you declare a function?
You declare a function using the syntax def function_name_here():
How do you call a function?
You call a function by using its name followed by parentheses, like
function_name()
What is a built-in function?
A built-in function is an action that can be called without needing to define it, those Tracy already knows how to perform
Tracy starts where in her world and facing which direction?
Tracy starts at 0,0 in the middle of her world facing to the right
What is the purpose of functions?
Functions help us shorten our code, make it reusable, and improve readability
What does indentation mean in functions?
Indentation in functions indicates which commands belong to the function, making the code organized and readable
What happens if you call a function not defined?
If you call a function that is not defined, an error will occur stating that the function is not recognized
Give an example of a user-defined function.
def draw_square():
def draw_two_circles():
def draw_big_rectangle():
These functions define new actions using commands
The circles radius
Give an example of a built-in function
circle()
forward()
penup()
pendown()
What is the syntax to call a function?
The syntax to call a function is
function_name()
How many times a function be called in a program?
A function can be called as many times as you need it to used in a program.
What's the difference between built-in and user-defined functions?
Built-in functions are predefined in the system, while user-defined functions are created by the programmer
What is the correct syntax to create a loop that will run 4 times?
for i in range(4):
What does it mean to define a function?
To define a function means to declare it using the syntax
def function_name_here(): followed by its commands.
What is wrong with the following function name:
Big_blue_circle():
It does not follow the naming guideline of not starting with a capital letter
What is the first line of code that would be executed in the following program:
The first line of code to execute is line 6 when the function draw_square() is called
Name one of the built-in functions in the following program.
for i in range(3):
forward(50)
left(120)
What does the 'i' in for i in range(2): represent?
iteration
Why are functions reusable?
Functions are reusable because they can be called multiple times without rewriting the code.
Create a function to have Tracy draw a square?
What would be the output of the following program:
This program has an error in line 6 so it will state there is an error and nothing will be drawn
How do you create a user-defined function?
You create a user-defined function using the def keyword followed by the function name and its commands
What is the value of "i" the first time a loop runs?
0