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
35 changes: 35 additions & 0 deletions BankAccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 3. BankAccount


class BankAccount:
def __init__(self,accountNumber,name,balance):
self.accountNumber = accountNumber
self.name = name
self.balance = balance

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

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

def bankFees(self):
self.balance = self.balance - (self.balance*0.05)
return self.balance

def desplay(self):
print(f"Bank Account Details:\nBank account number: {self.accountNumber}\nName: {self.name}\nBalance: {self.balance}")

acc = BankAccount(1234,"shatha",150)
acc.deposit(50)
acc.withdrawal(10)
acc.withdrawal(50)
acc.withdrawal(40)
acc.bankFees()
acc.withdrawal(100)
acc.desplay()
22 changes: 22 additions & 0 deletions Rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## 2. Rectangle

class rectangle:
def __init__(self,lng,wd):
self.lng = lng
self.wd = wd

def perimeter(self):
return 2*(self.lng+self.wd)

def area (self):
return (self.lng*self.wd)

def display(self):
print(f"Rectangle dimentions are {self.lng}, {self.wd}. Perimeter is {rectangle.perimeter(self)}. Area is {rectangle.area(self)}")



rect = rectangle(5,10)
rect.perimeter()
rect.area()
rect.display()
43 changes: 43 additions & 0 deletions School_Student.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## 1. School
class school:
s_lst = []
s_count = 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"Student name: {self.name}\nStudent age: {self.age}\nStudent gender: {self.gender}"

def add_student(self,capacity):
school.s_count = school.s_count +1
print(school.s_count)
if school.s_count <= capacity:
school.s_lst.append(self)
else:
print("Sorry this student can't be added as the school capacity is full")


def print_student(self):
for i in school.s_lst:
print(i.name,i.age,i.gender)


scl = school(3)
stdnt1 = student("Shatha",22,"F")
stdnt2 = student("hata",21,"M")
stdnt3 = student("Ali",29,"M")
stdnt4 = student("Farah",30,"F")
stdnt1.add_student(scl.capacity)
stdnt2.add_student(scl.capacity)
stdnt3.add_student(scl.capacity)
stdnt4.add_student(scl.capacity)
stdnt1.print_student()
print(stdnt1.__dict__)
print(scl.__dict__)