diff --git a/abstract.py b/abstract.py new file mode 100644 index 0000000..5c26d79 --- /dev/null +++ b/abstract.py @@ -0,0 +1,25 @@ +#amrutha_varshini +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() + 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() + 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()