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
12 changes: 12 additions & 0 deletions Project3_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def area(self):
return self.width * self.height
def perimeter(self):
return 2 * (self.width + self.height)

rectangle = Rectangle(5,7)
print("Area: ", rectangle.area())
print("Perimeter: ", rectangle.perimeter())
35 changes: 35 additions & 0 deletions Project3_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class School:
def __init__(self, name, fondation_year):
self.name = name
self.fondation_year = fondation_year
self.students = [] # ogrenciler listei
self.teachers = {} # ogretmenler sozlugu

def add_new_student(self, student_name, student_class):
self.students.append({"name" : student_name, "class" : student_class})
print(f"New Student added :{student_name} (class {student_class})")

def add_new_teacher(self, teacher_name, branch):
self.teachers[teacher_name] = branch
print(f"New Teacher added : {teacher_name} (branch : {branch})")

def view_student_list(self):
print("\nStudent_List")
for student in self.students:
print(f" - {student["name"]} (Class : {student["class"]})")

def view_teacher_list(self):
print("\nTeacher List:")
for teacher, branch in self.teachers.items():
print(f"- {teacher} (Branch: {branch})")

school = School("Green Valley High School", 1998)

school.add_new_student("Alice", "10A")
school.add_new_student("Bob", "9B")

school.add_new_teacher("Mr. Smith", "Mathematics")
school.add_new_teacher("Ms. Johnson", "English")

school.view_student_list()
school.view_teacher_list()
21 changes: 21 additions & 0 deletions Project3_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Shape:
def __init__(self,height,width):
self.height = height
self.width = width
class Rectangle(Shape):
def __init__(self,height,width):
super().__init__(height,width)
def area(self):
return self.height * self.width
class Square(Shape):
def __init__(self,side):
super().__init__(side,side)
def area(self):
return self.height * self.width
rect=Rectangle(10,15)
print(rect.area())
sqr=Square(10)
print(sqr.area())



40 changes: 40 additions & 0 deletions Question4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Vehicle:
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year

def display_info(self):
print(f"Make: {self.make}")
print(f"Model: {self.model}")
print(f"Year: {self.year}")


class Off_Road_Vehicle(Vehicle):
def __init__(self, make, model, year, four_wheel_drive):
super().__init__(make, model, year)
self.four_wheel_drive = four_wheel_drive

def display_info(self):
super().display_info()
print(f"Four Wheel Drive: {'Yes' if self.four_wheel_drive else 'No'}")


class Sports_Car(Vehicle):
def __init__(self, make, model, year, max_speed):
super().__init__(make, model, year)
self.max_speed = max_speed

def display_info(self):
super().display_info()
print(f"Max Speed: {self.max_speed} km/h")


offroad = Off_Road_Vehicle("Jeep", "Wrangler", 2023, True)
sports_Car = Sports_Car("Ferrari", "F8 Tributo", 2022, 340)



offroad.display_info()

sports_Car.display_info()
64 changes: 64 additions & 0 deletions Question5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
class Customer:
def __init__(self, name, surname, tc_identification, phone):
self.name = name
self.surname = surname
self.tc_identification = tc_identification
self.phone = phone

# def display_information(self):
# print(f"Name: {self.name}")
# print(f"Surname: {self.surname}")
# print(f"TC: {self.tc_identification}")
# print(f"Phone: {self.phone}")

def __str__(self):
return (
f"Customer Information\n"
f"---------------------------\n"
f"Name & Surname : {self.name} {self.surname}\n"
f"TC ID Number : {self.tc_identification}\n"
f"Phone Number : {self.phone}"
)



class Account(Customer):
def __init__(self, name, surname, tc_identification, phone, account_number, balance):
super().__init__(name, surname, tc_identification, phone)
self.account_number = account_number
self.balance = balance

def deposit(self, amount):
if amount > 0:
self.balance += amount
print(f"{amount} TL deposited successfully.")

def money_check(self, amount):
if amount <= 0:
print("Withdrawal amount must be positive.")
elif amount > self.balance:
print(f"Insufficient balance! Your current balance is {self.balance} TL.")
else:
self.balance -= amount
print(f"{amount} TL withdrawn successfully.")

def display_balance(self):
print(f"Account Number: {self.account_number}")
print(f"Current Balance: {self.balance:,.2f} TL")


customer_account = Account("Beyza Nur", "Sarıkaya", "12345678910", "0555-123-4567", "TR123456789", 5000)

print(customer_account.__str__())


customer_account.deposit(2000)

customer_account.money_check(1000)

customer_account.money_check(7000)
customer_account.display_balance()


print(customer_account.__str__())

Loading