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 BankAccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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:
self.balance-=w
else:
print ("Impossible operation! Insufficient balance!")
def bankFees(self):
self.balance -= (0.05* self.balance)
def display(self):
print(vars(self))

account1 = BankAccount(1,"rama",100)
account1.display()
account1.deposit(200)
account1.display()
account1.bankFees()
account1.display()
account1.withdrawal(50)
account1.display()
17 changes: 17 additions & 0 deletions Rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Rectangle:

def __init__(self,width,length):
self.width=width
self.length=length

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

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

def display(self):
print("Width is:", self.width, "\nLength is:", self.length, "\nArea is:",self.area(), "\nPerimeter is:", self.perimeter())

rec1=Rectangle(3,4)
rec1.display()
50 changes: 50 additions & 0 deletions school.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class School:
students =[]

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

def add_students(self,std):
if len(self.students)<self.capacity:
self.students.append([std.name,std.age,std.gender])
print(std.name, " was added")
else:
print(f"we cannot add",std.name,"as a new student. sorry, school capacity is full.")

class Student(School):

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

def __str__(self):
return self.name+" "+ str(self.age)+ " " + self.gender

def print_students():
for student in School.students:
print(student)


school1 = School(3)

std1=Student("rama",25,"female")
std2=Student("rami",20,"male")
std3=Student("mazen",30,"male")
std4=Student("hani",10,"male")

print(std3)

school1.add_students(std1)
school1.add_students(std2)
school1.add_students(std3)
school1.add_students(std4)

Student.print_students()

print(vars(std1))
print(vars(std2))
print(vars(std3))