Intro to Python Flashcards

1
Q

Build list so that the list first contains the name of each room as a string and then its area. ADD STRINGS IN SAME LINE: “hallway”, “kitchen” and “bedroom” at the appropriate locations.

A

areas = [“hallway”, hall, “kitchen”, kit, “living room”, liv, “bedroom”, bed, “bathroom”, bath]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Build list so that the list first contains the name of each room as a string and then its area. DO AS LIST OF LISTS:”hallway”, “kitchen” and “bedroom” at the appropriate locations.

A

house = [[“hallway”, hall],
[“kitchen”, kit],
[“living room”, liv],
[“bedroom”, bed],
[“bathroom”, bath]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Show/Print second element from df called ‘areas’

A

print(areas[1])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Use slicing to create a list, downstairs, that contains the first 6 elements of areas:
areas = [“hallway”, 11.25, “kitchen”, 18.0, “living room”, 20.0, “bedroom”, 10.75, “bathroom”, 9.50]

A

downstairs = areas[:6]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Use slicing to create upstairs, as the last 4 elements of areas

A

upstairs = areas[-4:]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly