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
29 changes: 29 additions & 0 deletions bank_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class BankAccount:
def __init__(self, accountNumber, name, balance):
self.accountNumber = accountNumber
self.name = name
self.balance = balance

def deposit(self,d):
self.balance+=d

def withdrawal(self , w):
if self.balance <w :
print (' Impossible operation! Insufficient balance!')
else:
self.balance-=w

def bankFees(self):
self.balance = self.balance - (self.balance*0.05)
return self.balance
def display(self) :
print (f'''
accountNumber: {self.accountNumber }
name: {self.name}
balance: {self.balance }''' )

b=BankAccount (567894,'accountHolder', 5000)
b.withdrawal(500)
b.deposit(10000)
b.bankFees()
b.display()
23 changes: 23 additions & 0 deletions rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width

def perimeter(self):
perimeter= 2 * (self.length + self.width)
return perimeter

def area (self):
area = self.length * self.width
return area

def display(self):
return f'''
length : {self.length }
width : {self.width }
perimeter :{self.perimeter()}
area : {self.area()}
'''

r1=Rectangle(3,4)
print (r1.display())
42 changes: 42 additions & 0 deletions school.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class school:
students = []
enrolment = 0
def __init__(self,capacity):
self.capacity = capacity

class student:
def __init__(self,name,age,gender):
self.name = name
self.age = age
self.gender = gender

def str (self):
return f'''
Name : {self.name}
Age : {self.age}
Gender : {self.gender}
'''
def add_student(self, capacity):
school.enrolment = school.enrolment + 1
if school.enrolment <= capacity:
school.students.append(self)
else:
print("Sorry class capacity is full")


def print_student(self):
for i in school.students:
print (i.str())

student1=student('Ali Sen', 19 ,'m')
student2=student('Ayse Sahin', 18,'f')
student3=student('Hasan Koc', 17, 'f')
class1= school (2)

student1.add_student(class1.capacity)
student2.add_student(class1.capacity)
student3.add_student(class1.capacity)

student1.print_student()
print(student1.__dict__)
print(class1.__dict__)