diff --git a/Home_Work4/1. School.py b/Home_Work4/1. School.py new file mode 100644 index 0000000..db2a5e4 --- /dev/null +++ b/Home_Work4/1. School.py @@ -0,0 +1,87 @@ +list_est = list() + +class School: + def __init__(self, capacity): + self.capacity = capacity + + def capacityFull(self): + full = self.__capacity = len(list_est) + if full > 0: + return full + + +class Student: + def __init__(self, name, age, gender): + self.name = name + self.age = age + self.gender = gender + + def addStudent(self): + print('*** Register Student***\n') + na = (input("Please put the name: ").upper()) + ag = (input("Please put the age: ")) + ge = (input("Please put gender: ").upper()) + est = Student(na, ag, ge) + list_est.append(est) + print("Succes ! \n") + + + + def Display(self): + + return (f''' + STUDENT DETAILS + ------------------ + Name : {self.name} + Age : {self.age} + Gender: {self.gender} + ''') + +def menu(): + + play= True + est = Student('',0,'') + + while play: + + print('\n*** Menu ***') + print('1. Add Student') + print('2. Display Student') + print("3. Exit") + try: + option = int(input("\nPlease choose you option: ")) + except: + print("\n ( ¬_¬) Wrong choice... (¬_¬) ") + continue + print() + + if option == 1: + + capt = School(0) + capt.capacityFull() + + if capt.capacityFull() ==3: + print('Sorry, capacity is full ! You can not be add more students ') + + else: + est.addStudent() + + elif option ==2: + + est_report = f''' + {'='*40} + {'STUDENT REPORT'.center(40)} + {'='*40}''' + + for estl in list_est: + est_report += estl.Display() + + print(est_report) + print() + + elif option ==3: + exit() + + else: + print('Wrong option') +menu() \ No newline at end of file diff --git a/Home_Work4/2. Rectangle.py b/Home_Work4/2. Rectangle.py new file mode 100644 index 0000000..d4cb4f8 --- /dev/null +++ b/Home_Work4/2. Rectangle.py @@ -0,0 +1,22 @@ +class Rectangle: + def __init__(self, length, width): + self.length = length + self.width = width + + def perimeter(self): + perimeter = (self.length*2)+(self.width*2) + return perimeter + + def area(self): + area = (self.length)*(self.width) + return area + + def __str__(self): + perim = rect.perimeter() + area = rect.area() + + return f'The length is: {self.length}\nThe width is: {self.width}\nThe perimeter is: {perim}\nThe area is: {area}' + +rect = Rectangle(8,2) + +print(rect) \ No newline at end of file diff --git a/Home_Work4/3. BankAccount.py b/Home_Work4/3. BankAccount.py new file mode 100644 index 0000000..d788506 --- /dev/null +++ b/Home_Work4/3. BankAccount.py @@ -0,0 +1,80 @@ +import time + +class BankAccount: + def __init__(self, accountNumber, name, balance): + self.accountNumber = accountNumber + self.name = name + self.balance = balance + + def deposit(self): + + time.sleep(0.5) + + print('*** Bank User deposit ***\n') + self.accountNumber = (input("Please put the Account Number: ")) + self.name = (input("Please put the Name: ").upper()) + self.balance = int((input(f"Please put the mount to deposit: "))) + + time.sleep(0.5) + + usr =BankAccount (f'{self.accountNumber}', {self.name}, {self.balance}) + list_bankacc = list() + list_bankacc.append(usr) + + usr_dcit = usr.__dict__ + print('\n',usr_dcit) + print("\n Succes !\n") + time.sleep(0.5) + + def withdrawal(self): + + print('*** Withdrawal ***\n') + + print(f"Yor balance is {self.balance}") + print() + wd = int((input("Please put the mount to Withdrawal: "))) + + time.sleep(0.5) + + if wd > self.balance: + print('Impossible operation, Insufficient funds !') + time.sleep(0.5) + exit() + else: + self.balance = self.balance - wd + + def bankFees(self): + + self.balance = self.balance - (self.balance * (5 / 100)) + + time.sleep(0.5) + + print(f"The bank have a fess (5 %), you tax is: {self.balance}") + + def Display(self): + + return (f''' + + USER DETAILS + ------------------ + Account Number : {self.accountNumber} + Name of User : {self. name} + Balance : {self.balance} + ''') + + +usr = BankAccount('','', 0) + +usr.deposit() + +usr.withdrawal() + +print() +usr.bankFees() + +est_report = f''' +{'='*40} +{'USER REPORT'.center(40)} +{'='*40}''' +print(est_report) +print(usr.Display()) \ No newline at end of file