YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Is Offered Solution - Intro to Computer Science

Get Embed Code
3 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. For the next few questions we're given this data structure of courses.
  2. Let's take a couple seconds to go through what it looks like.
  3. It's a dictionary where each key in the dictionary is a hexamester of courses that Udacity offers.
  4. In each hexamester we have another dictionary
  5. that's where the keys are the name of the course,
  6. and within that there's another dictionary with name value pairs.
  7. This is a common way to store data in an unstructured form
  8. where we just have an attribute like name, teacher, assistant, whatever--
  9. prereq down here--and then a value for that attribute:
  10. Building a Search Engine, the name of the TA, etc, etc.
  11. This question asks us to write a function
  12. that determines whether a course is offered during a given hexamester,
  13. and we're going to do that pretty simply.
  14. Before we get started, let's look at the data structure.
  15. What we want to do is, given a hexamester and the name of a course,
  16. we want to determine if that course is a key in the dictionary
  17. to which that hexamester is associated with.
  18. And this is just 1 line of code, actually.
  19. What this line of code does is determine whether or not the course is a key
  20. in the dictionary that we get with the keyword hexamester in our course's data structure.