CP104 Lecture 5: 7. Lists
Topic-7
● Sequence: stored in memory in multiple locations
● 1st item in location 0
○ We don't have to keep track of seperate 14 variables
■ E.g whale = [5,4,7]
■ To access count=whales[0]+whales[1]+.....+ whales [13]
■ 5 is in location 0
● Need to be able to create a list
○ assgn_grades= [80,90,100,75,80]
○ List (range(0,5))
■ [0,1,2,3,4]
○ list(5) ‘int’ object is not (error)
○ pay_list= [0]*5
○ empty_lis=[]
○ #Ths works too
○ empty_List= list() have to create empty list and then add stuff to it
○ friends=[‘MATT]’,’asmaa’]
■ print(friend(1))---->asmaa
○ For index in range(3):
○ len() takes ant interval and returns how many items are inside
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents