U2 Mod2 Activity 1
U2 Mod2 Activity 1
U2 Mod2 Activity 1
working with these structures. Students will be introduced to data structures and files in Python 3 and be ready for
more-advanced Python learning.
emptyList = [ ]
sampleList = [1, 1, 2, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5]
List object types are not restricted so a mix of object types can be in single list
Examples
7. # [ ] review, key and run example
# define list of strings
footBones = ["calcaneus", "talus", "cuboid", "navicular", "lateral cuneiform", "intermediate cuneiform", "medial
cuneiform"]
10. Create teamNames list and populate with 5 team name strings
a. Print the list
11. Create listMix and populate with integers, decimal, strings and teamNames list with a total of 10 items
a. Print the list
12. View this Video – Accessing Lists
To access the first item in a list use the list name, followed by square brackets containing the index number
ageSurvey[0]
Examples
13. # [ ] review and run example
print(ftBones[0], "is the 1st bone on the list")
print(ftBones[2], "is the 3rd bone on the list")
print(ftBones[-1], "is the last bone on the list")
18. FIX THE CODE (need to add a line of code and ensure it will run):
print(“ Total of check 3 & 4 = $ ”, payChecks[2] + payChecks [3]
19. Thoroughly test your code, check comments and then submit according to teacher instructions.
20. Take the activity quiz.