Skip to content

Instantly share code, notes, and snippets.

View kcsanjeeb's full-sized avatar
🎯
Focusing

sanjeeb kc kcsanjeeb

🎯
Focusing
  • offix services pvt. ltd.
  • kapan, kathmandu
  • X @sanjeebkc9
View GitHub Profile
from abc import ABCMeta, abstractmethod
class Employee(metaclass=ABCMeta):
@abstractmethod
def create(self):
pass
class manager(Person):
def create(self, name):
from abc import ABCMeta, abstractmethod
class Section(metaclass=ABCMeta):
@abstractmethod
def describe(self):
pass
class PersonalInfoSection(Section):
def describe(self):
print("Personal information section")
class A(object):
def a1(self):
print("a1")
class B(object):
def b(self):
print("b")
A().a1()
objectB =B()
objectB.b()
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)
class B:
class A:
def a1(self):
print("a1")
class B(A):
def b(self):
print("b")
b = B()
b.a1()
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")
@kcsanjeeb
kcsanjeeb / encapsulation.py
Last active July 20, 2020 15:17
code sample 1
class Chocolate:
def __init__(self):
self.__maxprice = 290
def sell(self):
print("Selling Price:{}".format(self.__maxprice))
def setMaxPrice(self, price):
self.__maxprice = price