What is the data type of None?
None.
What is the difference between a while and a for loop?
While Loop: does something for an infinite number of times UNTIL a condition is met.
For Loop: does something for a certain number of times only.
Return statements.
To Anya - show/create an example.
How many data types can a list contain?
One.
What is the most common phrase used to describe the difference between lists and tuples?
Tuples are immutable.
What are the five main types of data?
BONUS: list two more data types (double the points).
1. Boolean (True/False)
2. Integers
3. Float
4. Strings
5. None
BONUS: tuples & lists
While Loops: what is the difference between using return False or break to exit the while loop?
return False: exits the while loop AND the entire program.
break: exits the while loop only.
What function turns a string into an integer?
int()
Ex: int(string)
What is the LENGTH the list below?
my_list = ['random', 'bob', 'choo choo', 'sneeze']
BONUS: what is the index number of 'choo choo'?
Length: 4
BONUS: 2
What are the 4 patterns to find data in a tuple?
1. Mapping/Transform
2. Accumulator
3. Filter
4. Selection
What is the difference between "=" and "=="?
"=" means "to assign" something to something else. Mostly used with variables and data.
"==" used for comparisons in while & for loops, means "equal to".
What does i reference?
numbers = [1, 2, 3, 4, 5]
floats = []
for i in numbers:
floats.append(float(i))
The index number.
To distinguish a method/function from a variable, what is needed?
The parentheses.
Example:
addition = some_data
addition()
Question 10 on midterm practice test, what does the following code print out?
c. 4.0
How do you write a tuple?
my_tuple = ('string_var', float_var, int_var,...)
What does % do?
Example:
2 % 1 = ?
Returns the remainder.
2 / 1 = 2
2 % 1 = 0
What is the term we call i?
numbers = [1, 2, 3, 4, 5]
floats = []
for i in numbers:
floats.append(float(i))
i is the iterator.
Question 9 on midterm practice test, how many times is the function less() used?
5 times.
Question 8 on midterm practice test, what does the following code print out?
c. [10, 8, 7, 2]
Volunteer one person from your team to demonstrate the accumulate pattern with a tuple.
- Use numbers & floats!
Depends on my mood.
What are the results of:
7 // 2 = ?
7 / 2 = ?
7 % 2 = ?
7 ** 2 = ?
7 // 2 = 3
7 / 2 = 3.5
7 % 2 = 1
7 ** 2 = 49
my_list = [("Emma", 80.0), ("Fred", 34.0), ("Quentin", 14.9)]
for name, grade in my_list:
if name == "Fred":
print(grade)
break
1. What data type is grade?
2. What is the index number?
3. What is grade?
1. What data type is grade? Float
2. What is the index number? 1
3. What is grade? 34.0
Question 14 on the practice midterm, what does the following code print out?
b. South > north, with 3 deliveries.
Why can lists hold tuples (that hold multiple kinds of data types) but lists cannot hold more than one data type without a tuple?
A tuple is also a data type.
Volunteer one person from your team to demonstrate the select pattern with a tuple.
- Use integers & strings!
Depends on my mood.