What will this print?
var1 = true
var2 = true
if var1 and var2:
print("Woohoo!")
Woohoo!
What is the name of this function?
def eat_pie():
print("I like pie")
eat_pie
What is the name of this list?
trees = ["cherry", "oak", "birch", "redwood", "willow"]
trees
What is wrong here?
var1 = "pineapple"if (var1 = "pineapple"):
print("Unfortunately, we will never get to this print statement")
Should be ==, not =
What is the problem here?
print("Hi')
Should be two " " instead of '
What will print?
x = 3
if (5*x == 10 or 100<x):
print("go you")
nothing.
What is the return type of function func?
def func():return "5"
A string
What will this print?
my_list = ["hi", "what's up", "how are you"]
print(my_list[1])
what's up
What will happen when we run this code?
def sum(int num):
print(num)
Error-- we don't declare variable types in Python
What does it mean to concatenate two strings? What symbol do we use for it?
Combine strings using +
x = 5
if (8*x ==40 and 2*x < 3):
print("cool")
else:
print("oh no")
oh no
What happens we call this function?
def function3():
print("Hi!")
print("I'm a function that return true when I'm done printing")
return True
An error-- we forgot about indentation
What will this print?
my_list = ["hi"]
my_list.append("hey")
my_list.insert(1, "sup")
print(my_list)
["hi", "sup", "hey"]
What will happen?
function myfunction(){
print("This is my function, cool!")
}
An error-- we use the keyword def, not function, and we use : instead of {}
What will this print?
my_list = [3,2]
for index in range(0, len(my_list)):
print(index)
print(my_list[index])
0
3
1
2
What happens when we run this code?
def fun(num):
return i+7
def main():
answer = input("Give us a number!")
print(fun(answer))
if __name__ = "__main__":
main()
list = [1,5,7,9]
for num in range(len(list)):
list[num] += 1
print(list)
What will the new list print?
[2,6,8,10]
What will this print?
my_list = ["hi", "how are you", "hey"]
for greeting in my_list:
print(greeting)
hi
how are you
hey
colors = [“blue”, “red”, yellow”]
colors.append(“green”)
colors.insert(“purple”, 1)
colors.append(“black”)
colors[2] = “orange”
for color in colors:
print(color)
blue
purple
orange
yellow
green
black