This is what you use to store data or information
What is a variable?
age = 16
print("You are " + age + " years old.")
What is a TypeError?
x = 5
print(x+3)
What is 8?
This is the result of the following:
print("Hi" + "class")
What is "Hiclass"?
The four different variables we have talked about
integers, floats, booleans, and strings
This type of statement allows your program to choose between different paths based on a condition.
What is an if statement?
x=5
if x =2:
print("This number is 2.")
else:
print("This number is not 2.")
What is a missing equal sign?
for i in range(3):
print(i)
What is 0, 1, and 2
This is the result of the following:
print("ha" * 2)
haha
These are used to document your functions and provide those reading your code with explanations as to how your code works.
What are comments?
This keyword lets you exit out of a loop early
What is a break statement?
positive = 10
while positive > 0:
print("This number is positive")
What is an infinite loop?
for i in range(5, 1, -1):
if i % 2 == 0:
print(i)
What is 4 and 2?
name = "Jordan"
print(name[1])
What is "o"?
Difference between using a set of if statements vs elif statements.
A set of if statements run regardless of the previous condition. A set of elif statements only run if previous condition was not true.
You would use this kind of loop to repeatedly ask a user for an input until they type in “quit”.
def add(a, b):
return a + b
add(2)
What is missing a parameter?
for i in range(5):
if i % 2 == 0:
continue
print(i)
What is 1 and 3?
my_string = my_string[:5] + ":)"
print(my_string)
What is "hello :)"
These are the 3 different logical operators.
What are AND, OR, NOT?
This pair of keywords is used to handle errors and prevent your program from crashing.
What are try and except?
def square(n):
result = n * n
print(square(5))
What is a missing return statement?
x = 3
def update(x):
x = x + 2
return x
update(x)
print(x)
What is 3?
text = "random stuff"
other_text = "days"
print(text[:100] + other_text[-2])
What is "random stuff y"
The difference between interpreted language and a compiled language.
A compiled language is converted into machine code so that the processor can execute it. An interpreted language is a language in which the implementations execute instructions directly without earlier compiling a program into machine language