Return to Video

02-20 Red Englishman Solution

  • 0:00 - 0:04
    [Norvig] And the answer is all we have to do is check to see if Englishman
  • 0:04 - 0:06
    and red have been assigned the same house number.
  • 0:06 - 0:09
    And we just do that with saying if (Englishman == red).
  • 0:09 - 0:12
    And I should note just as an aside
  • 0:12 - 0:17
    if you wanted to be sort of clever and make it look more like English,
  • 0:17 - 0:21
    in this case it would be okay to say if (Englishman is red)
  • 0:21 - 0:26
    because is is checking for whether 2 objects are identically the same object.
  • 0:26 - 0:29
    Equals checks to see if they have the same value.
  • 0:29 - 0:33
    And it turns out that Python handles small integers like 1, 2, 3, 4, and 5
  • 0:33 - 0:36
    as a single identical object.
  • 0:36 -
    So the is check would work as well as the equals check here.
Cím:
02-20 Red Englishman Solution
Leírás:

more » « less
Team:
Udacity
Projekt:
CS212 - Design of Computer Programs
Duration:
0:40
Amara Bot hozzáadott egy fordítást

English subtitles

Felülvizsgálatok