what is wrong with this code?
print("hello world')
mismatched quotation marks
if x = 10:
print("x is 10")
elif x < 10:
print("less than 10")
else:
print("greater than 10")
no double equal
write a for loop that counts from 1 to 10 by 3s.
for i in range(1,11,3):
print(i)
def
how do I change "football" to "swimming"?
sports[2] = "swimming"
When do I need to indent a line of code?
After a colon when we are trying to represent that a piece of code is inside another piece of code
How many elifs can I have after 1 if statement?
as many as you want
what is the difference between a for loop and a while loop?
For loop is used when the number of iterations is already known. While loop is used when the number of iterations is unknown. (Other answers are acceptable as well)
how many parameters can you have in a function?
how do I add z to the list?
letters.append("z")
what is wrong with this code? Name 3 things
num = 3
if num != 5
print("not equal!")
else:
print("equal!")
no colon after if, no indentation of print("not equal!") and the else is indented under the if
Do I always have to have an else statement after an if/elif statement?
No
What is the output of this loop?
i=10
while 7 * 3 >= 21:
print(i)
i-=1
infinite loop
what will print when I run this program?
def sum(a,b):
print(a + b)
nothing. the function was never called
what is the error that will appear when I run this code? (as close to actual error as possible)
num = input("Enter a number to add to 3: ")
sum = num + 3
print(sum)
can only concatenate str (not "int") to str
what is the error in this code and how would i fix it?
num = int(input("enter a number: "))
print(num + " is the number you chose!")
cannot concatenate ints and strings must use str() around num to use plus sign with it
list 6 Python operators (partial credit is possible)
<, <=, >, >=, ==, !=
output?
x = 50
while x > 5:
print(x)
x /= 2
50
25.0
12.5
6.25
name the three parts of a function
function header, function body, and function call
What are three rules to naming variables?
no python keywords, can't start with numbers or symbols, cannot have spaces in the name
def max(a, b)
If a > b:
print("a is greater!'}
else a < b
print("b is greater")
no colon after def, mismatched quotations, mismatched brackets, no condition for else, no colon after else, print is not under else, no function call
write a program using conditionals that checks if a number is even.
num = int(input("enter a num: "))
if num % 2 == 0:
print("even")
else:
print("odd")
What is the output?
food = ["apple","grape","cookie","bread"]
for i in range(0,4):
print(food[i] + ",")
apple,
grape,
cookie,
bread,
What is the difference between parameters and arguments?
name as many of your classmates (on other teams) and what they like to do as you can. points will be awarded based on how many you can get correct.