diff --git a/bank_account.py b/bank_account.py new file mode 100644 index 0000000..9c41600 --- /dev/null +++ b/bank_account.py @@ -0,0 +1,39 @@ +#Python program to create BankAccount class +#with both a deposit() and withdraw function. + +#create the constructor with parameters: account_number, name and balance +class BankAccount: + def __init__(self, account_number, name, balance): + self.account_number = account_number + self.name = name + self.balance = balance + + #create deposit() method + def deposit(self): + amount = float(input('Enter amount to be deposited: ')) + self.balance += amount + + #create withdrawal() method + def withdrawal(self): + amount = float(input('Enter amount to be withdrawn: ')) + if self.balance < amount : + print('Impossible operation! Insufficient balance!') + else: + self.balance -= amount + + #create bankFees() method + def bankFees(self): + self.balance = (95/100)* self.balance + + #create display() method + def display(self): + print('\nAccount Number :' , self.account_number) + print('Account Name :' , self.name) + print('Account Balance :' , self.balance , '€') + + +print('Hello! Welcome to Deposit & Withdrawal Machine') +new_account = BankAccount(account_number=int(input('Account Number: ')), name=input('Account Name: '), balance=int(input('Account Balance: '))) +new_account.withdrawal() +new_account.deposit() +new_account.display() \ No newline at end of file diff --git a/rectangle.py b/rectangle.py new file mode 100644 index 0000000..5f2f658 --- /dev/null +++ b/rectangle.py @@ -0,0 +1,25 @@ +# Python program to create Rectangle class +class Rectangle: + #define constructor with attributes: lenght and width + def __init__(self, length, width): + self.length = length + self.width = width + + #create perimeter() method + def Perimeter(self): + return 2*(self.length + self.width) + + + #create Area() method + def Area(self): + return self.length * self.width + + #create display() method + def display(self): + print('The length of rectangle is :', self.length) + print("The width of rectangle is: ", self.width) + print("The perimeter of rectangle is: ", self.Perimeter()) + print("The area of rectangle is: ", self.Area()) + +my_rectangle = Rectangle(length=int(input('Length: ')), width=int(input('Width: '))) +my_rectangle.display() diff --git a/school.py b/school.py new file mode 100644 index 0000000..f125626 --- /dev/null +++ b/school.py @@ -0,0 +1,38 @@ +class School: + capacity = 1 + dict_of_class = {} + + +class Student(): + def __init__(self, firstname, lastname, age, gender = 'Unknown'): + self.firstname = firstname + self.lastname = lastname + self.age = age + self.gender = gender + + def add_student(self, capacity): + self.capacity = School.capacity + School.capacity += 1 + if School.capacity < 6: + School.dict_of_class[self.firstname + self.lastname] = [self.firstname, self.lastname, self.age, self.gender] + + else: + print('Error! Class is full! ') + + + def __str__(self): + return (f'\nStudent name: {self.firstname} {self.lastname}\nStudent Age: {self.age}\nStudent Gender: {self.gender}') + +first_class = School() +student1 = Student('Rumi', 'Yakar', 25, 'Female') +student1.add_student(first_class.capacity) +student2 = Student('Said', 'Bostan', 26, 'Male') +student2.add_student(first_class.capacity) +student3 = Student('Sami', 'Yakar', 24, 'Male') +student3.add_student(first_class.capacity) +student4 = Student('Ahmet', 'Yakar', 10, 'Male') +student4.add_student(first_class.capacity) +print(student2) +print(student2.__dict__) +print(first_class.dict_of_class) +