1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
return statement required?
NO
functions do not need a return statement
where does a function go?
back to where it was called to see if there is more code to evaluate
return replaced with print?
a return statement cannot be replaced with a print statement
print after return
will raise an error because print references unreachable code
functions defined after reference in another?
if the main function is called after the other functions are defined, it is fine to enter because they are defined already
relative reassignment operator
only one =
not two ==: means that elements are equal to each other
changes are global
if a value is passed to a function and then modified, those changes are reflected globally
manipulation of object
the function does not copy the object
instead, it directly manipulates the original object
for loops
CANNOT print indexes
can print indexes with a while loop and for ... in range loop
be careful with variables - sometimes python will mess up with local and global variables
unit tests
do not forget the return type
modifying a key in a dict
update to the new key with the correct value
remove the old key with the pop method
init return
returns a reference number to the heap
doesn't take self as an argument but always has it as a parameter
self.attribute, SELF.ATTRIBUTE
methods in a class
when you define a method in a class, all objects of that class have that method associated with it
constructor calling
you don't have to have an instance of a class to call the class's constructor