Name the 4 types of variables we went over in this camp
int, float, boolean, string
Your conditions in an if statement will be what kind of expressions? What do they equate to?
Boolean Expressions! (True or False)
What are the two loops we went over?
For loops and while loops
Keyword you need in functions
def
Name the 4 different times of aggregate data
lists, sets, tuples, dictionaries
What do we need to concatenate two strings together? Concatenate a string and number?
two strings is + and string and number is ,
What type of variable is n?
n= input("Enter something")
string
What is the sequence that is given by range(10)
0,1,2,3,4,5,6,7,8,9
What are the things you pass into a function called?
Which data aggregate can also be described as key:value pairs.
Dictionary
What is the escape sequence to create a horizontal tab
\t
How can we cast the input from string to FLOAT!
n = input("Enter something here")
n = float(input("Enter something here"))
How do you make sure your while loop does not turn into an infinite loop?
Make sure you increment a variable and/or cause the condition to eventually become false
How do you call a function?
function_name()
Which aggregate uses parenthesis and which uses curly brackets?
-not including dictionary
parentheses: tuples
curly brackets: sets
What will this equal?
47 % 3
2
What will print?
a = True
b = False
if a and b:
print("Hello World")
else:
if not(a and b):
print("Hi World")
else:
print("What’s up World")
"Hi World"
Using a for loop, how would you print out the numbers 0-10
for i in range(11):
print(i)
What is wrong here?
def multiply(x,y,z):
return x*y*z
print(“The answer is “, x*y*z)
There is something after the return statement; Return statements should always be last!
list = [ [1,2,3], [4,5,6], [7,8,9] ]
What value is list[2][1]
8
What will this equate to?
not True or True and not False or False
True
I want to check if a number is odd, what is the condition:
num = int(input("Enter a number here"))
if _______:
print("This is an odd number")
else:
print("This is an even number")
num % 2 == 1
Describe how you would print out the numbers from 1-10 using a while loop.
num = 1
while (num <=10):
print(num)
What will be the following output?
def square(x):
y = x * x
return y
print(square(square(2)))
16
How can I append a value to a list?
list = []
value = 7
list.append(value)