What is needed to Trace the code?
A way to track the variable change
What are the outputs for:
for i in range(1, 6):
print(i)
1
2
3
4
5
Why do we use if/else reasoning?
It is a conditional statement
what is wrong with this
name = input(what is your name? )
print("Hello", name)
In line 1 the quotations are missing
What coding language are we using to code in this class?
Python
What is this code tracing?
for i in range(4,25):
if i % 2 == 0:
print("Even")
else:
print("Odd")
It is tracing if numbers 4-24 is Odd or Even
What would be the total
total = 0
for i in range(2, 8, 2):
total += i
print(total)
12
If the budget was 250 what would it print out?
budget = 200
if budget >= 250:
print("You may go to the mall")
else:
print("Save up")
You may go to the mall
What is wrong with this:
age = (input("What is your age"))
if age < 13:
print("Child")
elif age < 18:
print("Teen")
else:
"Adult"
Line 1 missing “Int()” to turn string into integer and line 8 missing “print()”
What is a “code”
Code is a set of instructions written in a programming language that tells a computer what to do
What is missing?
for i in range(3,24):
print()
if i < 10:
print("Small")
else:
print("Big")
Line 2 is missing what to print and line 6 has no indentation after the “Else:”
What would the final count be?
count = 0
for i in range(1, 6):
if i % 2 == 0:
count += i
else:
count -= 1
print(count)
3
What would be considered “Premium meal”
food = input("Choose a food option (1–4): ")
extras = input("Do you want extras? (yes/no): ")
if food == "3" or food == "4":
if extras == "yes":
print("Premium meal with extras selected")
else:
print("Premium meal")
if food == "1" or food == "2":
if extras == "yes":
print("Standard meal with extras")
else:
print("Standard meal without extras")
3 or 4 and no
What is wrong with this:
time = input("What time is it?: ")
day = input("What day is it today?: ")
if day == "saturday" or day == "sunday"
Line 1 missing “int()” and its missing a “:” in line 4
Why do we need code in computers?
We need code to tell computers how to work and what tasks to perform.