What does the "float" function do? - ANSWERUsing float allows the input to be
converted to a decimal when needed for a calculation.
If you want to round your value to a certain decimal place when inside the print
statement, how would you go about it? - ANSWERprint (f'{x : .2f} {y : .2f} {z : .2f}')
this will print the values all rounded to 2 decimal places
When you add these two lists together, what are the results?
vec1 = [1, 2, 3]
vec2 = [0, 1, -1] - ANSWER[1, 2, 3, 0, 1, -1]
If you are relating two lists to each other and want to know what value something
holds in the other list, what do you do? For example, given a list with months and a
separate list with days, how would you find out how many days are in a given
month? - ANSWERGiven month_name prompted from the user we can match that
with how many days in that month:
month_days = days[month.index(month_name)]
When searching in a dictionary, what would an example of the code look like? -
ANSWERdays_in['Feb'] will return what is on the right side of the colon from Feb.
What is the difference between a lists, tuples, and dictionaries? - ANSWERA list can
be changed, or is "mutable", and is made with brackets []
A tuple is not able to be changed, or is "immutable", and it made with parenthesis ()
A dictionary allows for easy access to information associated with a search key, and
made up of braces {} and colons :. To the left of the colon is what you search for and
the object on the right is what Python prints.
How do you add something to a list in a specific place? And give an example. -
ANSWERUse the insert method: L.insert(index, value)
Example: If you wanted to add February in the correct place in this list months =
['Jan', 'March', 'April', 'May', etc], you would type months.insert(1, 'Feb')
How do you tack something onto the end of the list? - ANSWERlist.append(value)
What is a problem with dictionaries that we ran into in Recitation? -
ANSWERDictionaries only remember the most resent instance of a value, so if you
have two search keys associated with the same value, for example the number 4,
only the most recent instance will be remembered, as it can only remember one
Which of the following best describes a software engineering process used by most
successful programmers? - ANSWERDesign a solution carefully; document the
design; then code accordingly