Which part of the statement is the condition?
If I am hungry, I will eat an apple
If I am hungry
You have 5 cupcakes and 3 friends. How many cupcakes will you have left if each friend has an equal amount of cupcakes?
5%2 =
2
The process of fixing errors is called...
debugging
Each value in a list is called...
an item
What sign is equals to?
==
What does an if statement check for?
You have 10 cupcakes and 5 friends. How many cupcakes will you have left over if each friend receives an equal amount?
10%5 =
0
This error occurs when you have violated the rules of python syntax. It can't understand what you are trying to do.
Syntax error
What number do you start with in indexing?
0
What sign is does not equal?
!=
What kind of statement is this?
If it's sunny, I'll go outside. Else, I'll stay inside.
Else statement
Now you have 9 cupcakes and 4 friends. How many cupcakes will you have left over if each friend receives an equal amount?
9%4 =
1
What type of error is this?
numerator = 10
denominator = 0
result = numerator / denominator
print(result)
run time error, because it is happens when the code tries to perform an operation that is not allowed.
How do you get access to the length of a list?
len
What is a string
""
How do you end an ELIF statement?
With an else
Now you have 4 cupcakes and 7 friends. How many cupcakes will you have left over if each friend receives an equal amount?
4%7 = 4
What kind of error is this?
# Program to calculate the average of two numbers
a = 5
b = 7
average = a + b / 2 # Incorrect calculation of average, it should be (a+b)/2
print("The average of", a, "and", b, "is", average)
Logical error, because it the code does not produce the expected output due to incorrect logic or algorithm.
my_list = ["a", "b","c"]
print(my_list[1])
b
What is a float?
An decimal
What will print in the console?
num = 200
if num > 50:
print("This is a big number!")
else:
print ("This is a small number!")
This is a big number!
Now you have 10 cupcakes and 2 friends. How many cupcakes will you have left over if each friend receives an equal amount?
10%2 = 0
What are the steps to fixing errors?
Read the error message carefully: When an error occurs, the computer will usually give you an error message that explains what went wrong.
Identify the line(s) of code causing the error: The error message will usually give you a line number or point to the specific line(s) of code that caused the error.
Use print statements: You can use print statements to help debug your code. You can add print statements to the code to check the values of variables or to see if the code is executing as expected.
Test the code: Students should test their code by running it with different inputs to see if it produces the expected results.
Repeat the process: If the code still doesn't work, you should repeat the process, starting from step 1, until you find and fix the error.
What will print in the console?
str_list = [“p”, “r”, “o”, “b”, “e”]
print(str_list[0])
print(str_list[4])
print(str_list[-5])
p
e
p
7 is what kind of data type?
integer