From cb9723ec89522d613898f9acb3ebc2b4e6ed9cba Mon Sep 17 00:00:00 2001 From: amruthavarshinii <36105249+amruthavarshinii@users.noreply.github.com> Date: Thu, 13 Dec 2018 15:23:29 +0530 Subject: [PATCH 1/4] Create abstract.py this is an example of abstract class having abstract methods and concrete methods --- abstract.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 abstract.py diff --git a/abstract.py b/abstract.py new file mode 100644 index 0000000..b1da7e3 --- /dev/null +++ b/abstract.py @@ -0,0 +1,24 @@ +from abc import ABC,abstractmethod +class new(ABC): + def display(self): + print("example of abstract class and methods") + @abstractmethod + def calculate(self,x): + pass + +class sub1(new): + def calculate(self,x): + print("square value is:",x*x) + +class sub2(new): + def calculate(self,x): + print("square root value is:",x**0.5) + +s1=sub1() +s1.calculate(16) +s1.display() + +s2=sub2() +s2.calculate(2564) +s2.display() + From 251cd0ab54c518b3f79585fdf9011cfc6723cb47 Mon Sep 17 00:00:00 2001 From: amruthavarshini Date: Thu, 13 Dec 2018 23:23:11 +0530 Subject: [PATCH 2/4] amruth_varshini added --- abstract.py | 1 + 1 file changed, 1 insertion(+) diff --git a/abstract.py b/abstract.py index b1da7e3..5c26d79 100644 --- a/abstract.py +++ b/abstract.py @@ -1,3 +1,4 @@ +#amrutha_varshini from abc import ABC,abstractmethod class new(ABC): def display(self): From 3c7de6a7933d3e6856c95b3a7a34247c8da01804 Mon Sep 17 00:00:00 2001 From: amruthavarshini Date: Thu, 13 Dec 2018 23:30:15 +0530 Subject: [PATCH 3/4] bannk.py file is added --- bank.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bank.py diff --git a/bank.py b/bank.py new file mode 100644 index 0000000..f9e33df --- /dev/null +++ b/bank.py @@ -0,0 +1,25 @@ +class account: + def __init__(self,initial_balance): + self.balance=initial_balance + + def deposit(self,amount): + self.balance=self.balance+amount + return self.balance + def withdraw(self,amount): + if(self.balance-amount < 0): + return "cannott be withdrawed requested amount" + else: + self.balance=self.balance-amount + return self.balance +class Bank: + def display(self): + initial_balance=int(input("Enter balance:")) + a1=account(initial_balance) + amount=int(input("Amount to be withdrawn:")) + print("remaining balance:",a1.withdraw(amount)) + amount=int(input("amount to be deposited:")) + print("total amount present:",a1.deposit(amount)) + +b1=Bank() +b1.display() + From 23a13469376f5f8dbfa4d165b9f39c65d08d865d Mon Sep 17 00:00:00 2001 From: rekhaunnam123 <45434620+rekhaunnam123@users.noreply.github.com> Date: Thu, 13 Dec 2018 23:46:33 +0530 Subject: [PATCH 4/4] Create inherit.py --- inherit.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 inherit.py diff --git a/inherit.py b/inherit.py new file mode 100644 index 0000000..abcb940 --- /dev/null +++ b/inherit.py @@ -0,0 +1,15 @@ +class square: + def __init__(self,x): + self.x=x + def area(self): + print("area of square is:",self.x*self.x) +class rectangle(square): + def __init__(self,x,y): + super(). __init__(x) + self.y=y + def area(self): + super().area() + print("area of rectangle is",self.x*self.y) + +r=rectangle(10,5) +r.area()