Skip to content

Instantly share code, notes, and snippets.

@tmikeschu
Last active May 31, 2019 02:04
Show Gist options
  • Save tmikeschu/277c67555b9d09790fdb0d176b070bcd to your computer and use it in GitHub Desktop.
Save tmikeschu/277c67555b9d09790fdb0d176b070bcd to your computer and use it in GitHub Desktop.

4.0.4 Do Now

  1. Log in to REPL

  2. Look at the following code:

# my_building is a representation of the apartments on each floor of my 3 story building
my_building = [
  ['apt1a', 'apt1b', 'apt1c'],  
  ['apt2a', 'apt2b', 'apt2c'],
  ['apt3a', 'apt3b', 'apt3c']
]
print("first floor: " + str(my_building[0]))
print("first floor, 3rd apartment: " + my_building[0][2])

Answer the following questions on a piece of paper:

  • What would the print functions print?
  • Why does the first print function need the str function in str(my_building[0]), but the second print function does not need str for my_building[0][2]?
  • How you would access the 2nd apartment of the 3rd floor (apt3b)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment