Lecture Materials

Questions & Answers

Q: Helloooo how we doing on this friday

A1:  My mind is consumed by the idea of a 106A meme contest! -Brahm

A2:  Good!! How are you?

Q: Quick preemptive question about assignment 5: does it need any material that will be covered on Monday, or are we good to go starting from when it's released?

A1:  You’re good to go

Q: when is chris gonna tell us the famous story of how he met his fiance :(

A1:  I’ll make sure it happens :)

Q: the final bracket in dictionary is a typo, right?

A1:  Yep, that should be a }

Q: Dictionary is supposed to end with a close elipse right?

A1:  Yep - }

Q: I can’t remember, can we look up something in a list by value to find the index it is at?

A1:  Yep - the .index function

Q: Is the ‘b, in dictionary supposed to be ‘b’c?

A1:  yes 'b'

Q: how does the program know what is the next key, is the key considered as a number, then?

A1:  The dictionary maintains an internal sense of what the next key is, but not quite as a number! Come to OH to chat more about how it works :)

Q: Is anyone else having trouble downloading lecture slides and code? It won’t open/download for me.

A1:  They’re working for me - what issue are you seeing?

Q: They just don’t download, either when I click on the code or download linked file.

A1:  Do you see an error page?

Q: No error page :(

A1:  Can you try on another browser?

Q: I’m confused on the problem because can’t we only have one unique key per value? So how could we reverse this?

A1:  We can, but multiple keys can share the same value, which is why we have lists in the reversed dictionary

Q: do we have to return a dictionary?

A1:  That’s the idea!

Q: I think we should create a new list and an if statement, right?

A1:  Good thinking :)

Q: Dont you have to create the list for value first?

A1:  We’re doing that now!

Q: why is Chris on a mac, but doesn’t have to write python3 in order to run a program?

A1:  He just changed a setting on his computer - you should use python3!

Q: Is there a way to use the key to reference the list (i.e. reversed[32]' for ['Chris','Rihanna']) and simultaneously take a specific element from the list (i.e. just 'Chris')? What would the syntax for this be?

A1:  Nope - but you can index into the list

Q: Why do we say “if not value in reversed” instead of “if value not in reversed”?

A1:  Either is fine

Q: so technically, key corresponds to one value but the value is a list, right?

A1:  Yes, the key is one value (of an immutable type)

Q: sorry, can you clarify why you renamed data[name]?

A1:  Just so the program was easier to read! It refers to the same list in memory

Q: When we change clolr_list we actually change the data[name] in the dictionary as well?

A1:  Yes, they refer to the same list in memory

A2:  Yes. color_list is just a reference to the value in the dictionary.

Q: shouldn’t load_data return color_list?

A1:  Nope, we want to return the entire dictionary, not just the list for one color

Q: I didn’t know pyhton can make the inputs lower case, does it do to capitals or other kind of inputs to generalize the function of the program?

A1:  Yep - check out the strings lecture for a comprehensive list!

Q: Why did you set color_list to data[name]?

A1:  Just to make the program easier to read - they refer to the same list in memory

Q: you can't do data[name].append([r g b]) ?

A1:  you can't do data[name].append([r g b]) ?

A2:  You can!

Q: pardon, can we clarify query.lower?

A1:  It just makes the string lowercase :)

Q: How do we know where to plot the colors on the canvas?

A1:  Great question! Stop by office hours to find out :)

Q: What determines where it plots the color on the canvas? Was that natural or did Chris specify this?

A1:  Great question! Stop by OH to find out :)

Q: how do you tab them all at once? like a bunch of lines

A1:  Highlight them and press tab :)

Q: Super curious about how that display is set up!

A1:  Stop by office hours :) I’ll explain it there!

Q: How do you plot the 3D rbg in 2d?

A1:  Stop by office hours :) I’ll explain it there!

Q: what does query = query.lower() do?

A1:  Makes it lowercase

Q: why do we plot r, g, b separately instead of color_rgb?

A1:  We pass them into color_rgb

Q: if we don’t have data[name] = [], and just do data[name].append([r,g,b]), will python just say that there is no key with “name” in the data dictionary?

A1:  Yep!

Q: Do we have enough knowledge to do the next pset yet?

A1:  live answered

Q: Doesn’t who and where the data in the dictionary comes from create biases? So what pops up on Google stem from the biases of the data?

A1:  live answered

Q: Why would you need to make query lowercase?

A1:  live answered

Q: Are any of you teaching 106B?

A1:  live answered

Q: Why are their much fewer US towns after that magic line you showed us last time

A1:  live answered

Q: what divided the US?? was it the great plains? I missed that part

A1:  live answered

Q: the ogalla aquifer?

A1:  live answered