what is super function ?
class A: def spam(self): print(1) class B(A): def spam(self): print(2) super().spam() B().spam() Since class A & class B have same method, it must overwritten and print 2 but instead of this it print 2 and 1 why?
~ swim ~ you didn't ans my full que..I also ask that since class A & class B have same method , it must overwritten and print 2 but instead of this it print 2 and 1..that part is not clear to me .can you give me proper explanation?..since I am not clearly understand from the course explanation !!!
From the definition of the method spam(self) in class B (which inherits from A), B().spam() will first print 2, then call the method spam from the superclass A, which prints 1.
BMI calculator code project
Overloading + operator
How to create a border