Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions abstract.py
Original file line number Diff line number Diff line change
@@ -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()

25 changes: 25 additions & 0 deletions bank.py
Original file line number Diff line number Diff line change
@@ -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()

15 changes: 15 additions & 0 deletions inherit.py
Original file line number Diff line number Diff line change
@@ -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()