Changes

Jump to: navigation, search

OPS445 Online Lab6

2 bytes added, 09:44, 4 March 2022
m
PART 2 - Understanding Class Structure
</source>
:# The method '''addGrade()''' changes the '''self.courses''' dictionary. But both student1 and student2 have their OWN courses dictionary.
:# Once an object is created the attributes inside may be modified externally. Though you may need to be careful, if a value is a string, and you change it to another type such as a integer or a list, it's possible the class was not designed to deal with the different type and may throw a error when you run a method. For example, changing the name to a integer would break the displayStudent method, because it would try and concatenate strings and integers(maybe the method should be written better).<source lang="python">
# student1.name is a string like any other
print(student1.name)
572
edits

Navigation menu