This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from abc import ABCMeta, abstractmethod | |
| class Employee(metaclass=ABCMeta): | |
| @abstractmethod | |
| def create(self): | |
| pass | |
| class manager(Person): | |
| def create(self, name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from abc import ABCMeta, abstractmethod | |
| class Section(metaclass=ABCMeta): | |
| @abstractmethod | |
| def describe(self): | |
| pass | |
| class PersonalInfoSection(Section): | |
| def describe(self): | |
| print("Personal information section") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A(object): | |
| def a1(self): | |
| print("a1") | |
| class B(object): | |
| def b(self): | |
| print("b") | |
| A().a1() | |
| objectB =B() | |
| objectB.b() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Adder: | |
| def __init__(self): | |
| self.sum = 0 | |
| def add(self,value): | |
| self.sum += value | |
| acc = Adder() | |
| for i in range(99): | |
| acc.add(i) | |
| print(acc.sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class B: | |
| class A: | |
| def a1(self): | |
| print("a1") | |
| class B(A): | |
| def b(self): | |
| print("b") | |
| b = B() | |
| b.a1() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Sparrow: | |
| def flight(self): | |
| print("Sparrow can fly") | |
| def swim(self): | |
| print("Sparrow can't swim") | |
| class Penguin: | |
| def flight(self): | |
| print("Penguin can't fly") | |
| def swim(self): | |
| print("Penguin can swim") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Chocolate: | |
| def __init__(self): | |
| self.__maxprice = 290 | |
| def sell(self): | |
| print("Selling Price:{}".format(self.__maxprice)) | |
| def setMaxPrice(self, price): | |
| self.__maxprice = price |
NewerOlder