Table of Contents

2nd computer lab

key terms

just excerpts from the live programming session

Class
__init__
return
some_array = [1,2,3]
if(v1 > v2):
for element in some_array:
 
if __name__ == "__main__":
   # do something as the main program
 
def get(self):
    return(self.time)

for practising

Improve the MyTime class such that it allows logical comparison t1>t2 is understood as is t1 later than t2, or is t1 longer than t2?

Class MyTime:
    def __init__(self,time):
        self.time = time
 
>>> t1 = MyTime([1, 20])
>>> t2 = MyTime([4, 10])
>>> t1 > t2
False

hint: __gt__

Reading