From 698747498fa2bc3d58698edf3c4d1c7a8760b56f Mon Sep 17 00:00:00 2001 From: zehraturan <78978788+zehraturan@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:05:12 +0200 Subject: [PATCH 1/3] Week5 Assignment is added --- bankaccount.py | 31 +++++++++++++++++++++++++++++++ rectangle.py | 19 +++++++++++++++++++ school.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 bankaccount.py create mode 100644 rectangle.py create mode 100644 school.py diff --git a/bankaccount.py b/bankaccount.py new file mode 100644 index 0000000..7e9a3e8 --- /dev/null +++ b/bankaccount.py @@ -0,0 +1,31 @@ +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() \ No newline at end of file diff --git a/rectangle.py b/rectangle.py new file mode 100644 index 0000000..c4a2e03 --- /dev/null +++ b/rectangle.py @@ -0,0 +1,19 @@ +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() \ No newline at end of file diff --git a/school.py b/school.py new file mode 100644 index 0000000..93652ef --- /dev/null +++ b/school.py @@ -0,0 +1,43 @@ +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__) From dd4a03de34fa1e648c03f1308d0d7ca1f9699cce Mon Sep 17 00:00:00 2001 From: zehraturan <78978788+zehraturan@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:15:30 +0200 Subject: [PATCH 2/3] Week4 Assignment --- school.py | 1 + 1 file changed, 1 insertion(+) diff --git a/school.py b/school.py index 93652ef..c8e9ee6 100644 --- a/school.py +++ b/school.py @@ -27,6 +27,7 @@ def __str__(self): return f'''Student name: {self.name}, age: {self.age}, gender: {self.gender}''' + school = School(2) std1 = Student('Jack','11','M') From c2e11880b7767258ce4600ea7c06fce250965e98 Mon Sep 17 00:00:00 2001 From: zehraturan <78978788+zehraturan@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:18:07 +0200 Subject: [PATCH 3/3] Week4 Assignment --- bankaccount.py | 1 + rectangle.py | 1 + 2 files changed, 2 insertions(+) diff --git a/bankaccount.py b/bankaccount.py index 7e9a3e8..02e7805 100644 --- a/bankaccount.py +++ b/bankaccount.py @@ -21,6 +21,7 @@ def display(self): Name: {self.name} Balance: {self.balance}''') + account = BankAccount(1223456, "Nadine", 5000) account.withdrawal(5100) diff --git a/rectangle.py b/rectangle.py index c4a2e03..27b205e 100644 --- a/rectangle.py +++ b/rectangle.py @@ -15,5 +15,6 @@ def display(self): Perimeter: {self.perimeter()} Area: {self.area()}''') + rec = Rectangle(12,15) rec.display() \ No newline at end of file