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
32 changes: 32 additions & 0 deletions bankaccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 w > self.balance:
print("Impossible operation! Insufficient balance!")
else:
self.balance -= w

def bankFees(self):
self.balance = (95/100) * self.balance

def display(self):
print (f'''Account Number: {self.accountNumber}
Name: {self.name}
Balance: {self.balance}''')


account = BankAccount(1223456, "Nadine", 5000)

account.withdrawal(5100)
account.display()
account.deposit(5300)
account.display()
account.bankFees()
account.display()
20 changes: 20 additions & 0 deletions rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width

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

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

def display(self):
print(f'''Rectangle Length: {self.length},
Width: {self.width},
Perimeter: {self.perimeter()}
Area: {self.area()}''')


rec = Rectangle(12,15)
rec.display()
44 changes: 44 additions & 0 deletions school.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class School:

students = []

def __init__(self, capacity):
self.capacity = capacity

def add_student(self, s):

if len(self.students) >= self.capacity :
print("The capacity is full. You can not register the student.")
else :
self.students.append(s)

def print_students(self):
for s in self.students:
print(s)

class Student:

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

def __str__(self):
return f'''Student name: {self.name},
age: {self.age},
gender: {self.gender}'''


school = School(2)
std1 = Student('Jack','11','M')
std2 = Student('Melissa','10','F')
std3 = Student('Ali','10','M')

school.add_student(std1)
school.add_student(std2)
school.print_students()

school.add_student(std3)

print(school.__dict__)
print(std3.__dict__)