CSC108H1 Lecture : november 30 notes
yifanyang and 39659 others unlocked
21
CSC108H1 Full Course Notes
Verified Note
21 documents
Document Summary
Classes have methods, can called methods on objects. Using ojects: you have used many kinds of objects that are built in python: int, str, list, >>> total = 0 #create a new int object. >>> ex. name = priya" # create a new str object: and others that are part of modules you had to import such as media. >>> p = media. get_pixel(pic, 3, 92) # returns a pixel object. Defining new types of objects: consider a calendar program. Messy: or we could define a new type of object to bundle these together, we have int, str, dict, list, ect. >>> e1 = event() # assigns e1 as an object. # can"t add instance variables in built in classes like strings. { start":9, end":10, name": 108 lecture"} # kept in dictionary. { start":9, end":10, name": 108 lecture", location": ba 1220"} # kept in dictionary.