From a7f873842006e263e8bdd3fded26b3d90af0c030 Mon Sep 17 00:00:00 2001 From: fahzey Date: Wed, 17 Sep 2025 13:55:26 +0200 Subject: [PATCH 1/4] =?UTF-8?q?3=C3=BCnc=C3=BC=20hafta=20sorular=C4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kutuphane.db | Bin 0 -> 20480 bytes kutuphane.json | 15 ++ week4.py | 418 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 433 insertions(+) create mode 100644 kutuphane.db create mode 100644 kutuphane.json create mode 100644 week4.py diff --git a/kutuphane.db b/kutuphane.db new file mode 100644 index 0000000000000000000000000000000000000000..e09a699ee2192acf8ba17bedcb2b6d147c696e04 GIT binary patch literal 20480 zcmeI#Jxjwt7{KwwR4YQ&K`0L5jSY&6lbcmeDb`eD1Ur>zPY9+}n>aYC;8*Z7y88h< zFQze~IJlMn!8Lc!<++z%y4=ZeJ4%(fydDk0RBT#{mTg$J%&yYkIU&d$AUx`M27uZcq?F009ILKmY**5I_I{1ag6+%1nK2&F-e*d90G# zSl`iliMqX0!;A0T>0Mto11W;$PFsp^?>2_vK&|Uc_i@&#)>l{Ur=FQp4Z@*HV>KE# zDy4bGVbPcqpC#&xmKVr<>5C)3b=dT~;y`vq^EBwRJe_?gy Date: Fri, 19 Sep 2025 23:35:32 +0200 Subject: [PATCH 2/4] week3 --- mini kutup.py | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++ s1.py | 19 ++++ s2.py | 48 ++++++++++ s3.py | 25 ++++++ s4.py | 42 +++++++++ s5.py | 50 +++++++++++ 6 files changed, 422 insertions(+) create mode 100644 mini kutup.py create mode 100644 s1.py create mode 100644 s2.py create mode 100644 s3.py create mode 100644 s4.py create mode 100644 s5.py diff --git a/mini kutup.py b/mini kutup.py new file mode 100644 index 0000000..7e28696 --- /dev/null +++ b/mini kutup.py @@ -0,0 +1,238 @@ +import json +import os + + +# ========== Kitap Sınıfları ========== +class Book: + def __init__(self, title, author, publication_year): + self.title = title + self.author = author + self.publication_year = publication_year + self.is_borrowed = False + self.borrowed_by = None + + def show_info(self): + status = f"Ödünçte ({self.borrowed_by})" if self.is_borrowed else "Müsait" + print(f"{self.title} - {self.author} ({self.publication_year}) | Durum: {status}") + + def borrow(self, user): + if not self.is_borrowed: + self.is_borrowed = True + self.borrowed_by = user.name + user.borrowed_books.append(self.title) + print(f"{self.title} başarıyla ödünç alındı.") + else: + print(f"{self.title} zaten ödünç alınmış!") + + def return_book(self, user): + if self.is_borrowed and self.borrowed_by == user.name: + self.is_borrowed = False + self.borrowed_by = None + user.borrowed_books.remove(self.title) + print(f"{self.title} başarıyla iade edildi.") + else: + print("Bu kitabı iade edemezsiniz!") + + def to_dict(self): + return { + "title": self.title, + "author": self.author, + "publication_year": self.publication_year, + "is_borrowed": self.is_borrowed, + "borrowed_by": self.borrowed_by, + "type": "Book" + } + + +class Novel(Book): + def __init__(self, title, author, publication_year, genre): + super().__init__(title, author, publication_year) + self.genre = genre + + def to_dict(self): + data = super().to_dict() + data["genre"] = self.genre + data["type"] = "Novel" + return data + + +class Magazine(Book): + def __init__(self, title, author, publication_year, issue): + super().__init__(title, author, publication_year) + self.issue = issue + + def to_dict(self): + data = super().to_dict() + data["issue"] = self.issue + data["type"] = "Magazine" + return data + + +# ========== Kullanıcı Sınıfı ========== +class User: + def __init__(self, name, password): + self.name = name + self.password = password + self.borrowed_books = [] + + def borrow_book(self, book): + book.borrow(self) + + def return_book(self, book): + book.return_book(self) + + def list_borrowed_books(self): + if not self.borrowed_books: + print("Henüz ödünç alınmış kitabınız yok.") + else: + print("Ödünç alınan kitaplar:") + for title in self.borrowed_books: + print(f"- {title}") + + def to_dict(self): + return { + "name": self.name, + "password": self.password, + "borrowed_books": self.borrowed_books + } + + +# ========== Kütüphane Sınıfı ========== +class Library: + def __init__(self, name): + self.name = name + self.books = [] + self.users = [] + + def add_book(self, book): + self.books.append(book) + + def add_user(self, user): + self.users.append(user) + + def show_all_books(self): + if not self.books: + print("Kütüphanede hiç kitap yok.") + else: + for i, book in enumerate(self.books, start=1): + print(f"{i}. ", end="") + book.show_info() + + def login(self, name, password): + for user in self.users: + if user.name == name and user.password == password: + print(f"Hoşgeldiniz, {name}!") + return user + print("Kullanıcı adı veya şifre hatalı.") + return None + + def save(self, file): + data = { + "name": self.name, + "books": [book.to_dict() for book in self.books], + "users": [user.to_dict() for user in self.users] + } + with open(file, "w", encoding="utf-8") as f: + json.dump(data, f, ensure_ascii=False, indent=4) + print("📁 Veriler kaydedildi.") + + def load(self, file): + if not os.path.exists(file): + return + with open(file, "r", encoding="utf-8") as f: + data = json.load(f) + + self.name = data["name"] + + # Kitapları geri yükle + self.books = [] + for b in data["books"]: + if b["type"] == "Novel": + book = Novel(b["title"], b["author"], b["publication_year"], b["genre"]) + elif b["type"] == "Magazine": + book = Magazine(b["title"], b["author"], b["publication_year"], b["issue"]) + else: + book = Book(b["title"], b["author"], b["publication_year"]) + book.is_borrowed = b["is_borrowed"] + book.borrowed_by = b["borrowed_by"] + self.books.append(book) + + # Kullanıcıları geri yükle + self.users = [] + for u in data["users"]: + user = User(u["name"], u["password"]) + user.borrowed_books = u["borrowed_books"] + self.users.append(user) + + +# ========== Ana Program ========== +def main(): + lib = Library("Merkez Kütüphane") + lib.load("library.json") + + # Örnek veri ekleyelim (ilk açılışta) + if not lib.books: + lib.add_book(Novel("Sefiller", "Victor Hugo", 1862, "Dram")) + lib.add_book(Magazine("Bilim Dergisi", "TÜBİTAK", 2023, "Ekim")) + lib.add_book(Book("Python 101", "Guido van Rossum", 1991)) + + while True: + print("\n=== Kütüphane Yönetim Sistemi ===") + print("1 - Giriş Yap") + print("2 - Kayıt Ol") + print("3 - Çıkış") + secim = input("Seçiminiz: ") + + if secim == "1": + name = input("Kullanıcı adı: ") + password = input("Şifre: ") + user = lib.login(name, password) + if user: + while True: + print("\n--- Menü ---") + print("1 - Tüm kitapları listele") + print("2 - Kitap ödünç al") + print("3 - Kitap iade et") + print("4 - Ödünç aldığım kitaplar") + print("5 - Kaydet ve çık") + choice = input("Seçiminiz: ") + + if choice == "1": + lib.show_all_books() + elif choice == "2": + lib.show_all_books() + idx = int(input("Kaç numaralı kitabı ödünç almak istiyorsunuz? ")) - 1 + if 0 <= idx < len(lib.books): + user.borrow_book(lib.books[idx]) + elif choice == "3": + user.list_borrowed_books() + title = input("İade etmek istediğiniz kitabın adı: ") + for book in lib.books: + if book.title == title: + user.return_book(book) + break + else: + print("Böyle bir kitabınız yok.") + elif choice == "4": + user.list_borrowed_books() + elif choice == "5": + lib.save("library.json") + return + else: + print("Geçersiz seçim.") + + elif secim == "2": + name = input("Kullanıcı adı: ") + password = input("Şifre: ") + lib.add_user(User(name, password)) + print("Kullanıcı başarıyla oluşturuldu.") + + elif secim == "3": + lib.save("library.json") + break + else: + print("Geçersiz seçim!") + + +if __name__ == "__main__": + main() diff --git a/s1.py b/s1.py new file mode 100644 index 0000000..057b3d0 --- /dev/null +++ b/s1.py @@ -0,0 +1,19 @@ +class Dikdortgen(): + def __init__(self, kisa_kenar, uzun_kenar): + self.kisa_kenar = kisa_kenar + self.uzun_kenar = uzun_kenar + + def alan(self): + return self.kisa_kenar * self.uzun_kenar + + def cevre(self): + return 2 * (self.kisa_kenar + self.uzun_kenar) + + +dikdortgen1 = Dikdortgen(5, 10) +print("Dikdörtgenin alanı:", dikdortgen1.alan()) + + +print("Dikdörtgenin cevresi:", dikdortgen1.cevre()) + + \ No newline at end of file diff --git a/s2.py b/s2.py new file mode 100644 index 0000000..9b00a3a --- /dev/null +++ b/s2.py @@ -0,0 +1,48 @@ +class Okul: + def __init__(self, isim, kuruluş_yılı): + self.isim = isim + self.kuruluş_yılı = kuruluş_yılı + self.öğrenciler = [] # öğrencileri sözlük olarak tutacağız: {"isim": ..., "sınıf": ...} + self.öğretmenler = [] # öğretmenleri sözlük olarak tutacağız: {"isim": ..., "branş": ...} + + def add_new_student(self, student_name, sınıf): + yeni_öğrenci = {"isim": student_name, "sınıf": sınıf} + self.öğrenciler.append(yeni_öğrenci) + print(f"{student_name} adlı öğrenci {sınıf} sınıfına eklendi.") + + def add_new_teacher(self, teacher_name, branch): + yeni_öğretmen = {"isim": teacher_name, "branş": branch} + self.öğretmenler.append(yeni_öğretmen) + print(f"{teacher_name} adlı öğretmen {branch} branşına eklendi.") + + def view_student_list(self): + if not self.öğrenciler: + print("Henüz öğrenci yok.") + else: + print(f"{self.isim} Okulundaki Öğrenciler:") + for öğrenci in self.öğrenciler: + print(f"- {öğrenci['isim']} ({öğrenci['sınıf']} sınıfı)") + + def view_teacher_list(self): + if not self.öğretmenler: + print("Henüz öğretmen yok.") + else: + print(f"{self.isim} Okulundaki Öğretmenler:") + for öğretmen in self.öğretmenler: + print(f"- {öğretmen['isim']} ({öğretmen['branş']} öğretmeni)") + + +# Okul oluşturma +okul = Okul("Hilversum Anadolu Lisesi", 1998) + +# Öğrenci ekleme +okul.add_new_student("Ahmet Yılmaz", "10A") +okul.add_new_student("Ayşe Demir", "9B") + +# Öğretmen ekleme +okul.add_new_teacher("Mehmet Kaya", "Matematik") +okul.add_new_teacher("Fatma Koç", "Fizik") + +# Listeleri görüntüleme +okul.view_student_list() +okul.view_teacher_list() diff --git a/s3.py b/s3.py new file mode 100644 index 0000000..144b63a --- /dev/null +++ b/s3.py @@ -0,0 +1,25 @@ +# Ana sınıf (Şekil) +class Sekil: + def __init__(self, genislik, yukseklik): + self.genislik = genislik + self.yukseklik = yukseklik + + +# Dikdörtgen sınıfı +class Dikdortgen(Sekil): + def calculate_area(self): + return self.genislik * self.yukseklik + + +# Kare sınıfı +class Kare(Sekil): + def calculate_area(self): + return self.genislik * self.yukseklik + + +# Örnek kullanımlar: +dikdortgen = Dikdortgen(5, 10) # genişlik=5, yükseklik=10 +kare = Kare(7, 7) # genişlik=7, yükseklik=7 + +print(f"Dikdörtgenin Alanı: {dikdortgen.calculate_area()}") +print(f"Karenin Alanı: {kare.calculate_area()}") diff --git a/s4.py b/s4.py new file mode 100644 index 0000000..1a24bdf --- /dev/null +++ b/s4.py @@ -0,0 +1,42 @@ +# Temel sınıf +class Vehicle: + def __init__(self, marka, model, yil): + self.marka = marka + self.model = model + self.yil = yil + + def display_info(self): + print(f"Marka: {self.marka}, Model: {self.model}, Yıl: {self.yil}") + + +# Arazi Aracı (SUV) sınıfı +class SUV(Vehicle): + def __init__(self, marka, model, yil, dort_ceker): + super().__init__(marka, model, yil) + self.dort_ceker = dort_ceker # True/False + + def display_info(self): + super().display_info() + print(f"Dört Tekerlekten Çekiş: {'Evet' if self.dort_ceker else 'Hayır'}") + + +# Spor Araba sınıfı +class SportCar(Vehicle): + def __init__(self, marka, model, yil, max_speed): + super().__init__(marka, model, yil) + self.max_speed = max_speed + + def display_info(self): + super().display_info() + print(f"Maksimum Hız: {self.max_speed} km/s") + + +# Örnek kullanım +suv_arac = SUV("Toyota", "Land Cruiser", 2022, True) +spor_araba = SportCar("Ferrari", "488 GTB", 2021, 330) + +print("SUV Aracı Özellikleri:") +suv_arac.display_info() + +print("\nSpor Araba Özellikleri:") +spor_araba.display_info() diff --git a/s5.py b/s5.py new file mode 100644 index 0000000..a9b93be --- /dev/null +++ b/s5.py @@ -0,0 +1,50 @@ +# Müşteri sınıfı +class Musteri: + def __init__(self, isim, soyad, tc_identification, telefon): + self.isim = isim + self.soyad = soyad + self.tc_identification = tc_identification + self.telefon = telefon + + def display_information(self): + print(f"Müşteri Bilgileri:\n" + f"Ad: {self.isim}\n" + f"Soyad: {self.soyad}\n" + f"TC: {self.tc_identification}\n" + f"Telefon: {self.telefon}") + + +# Hesap sınıfı (Müşteri'den miras alıyor) +class Hesap(Musteri): + def __init__(self, isim, soyad, tc_identification, telefon, hesap_numarasi, bakiye=0): + super().__init__(isim, soyad, tc_identification, telefon) + self.hesap_numarasi = hesap_numarasi + self.bakiye = bakiye + + def deposit(self, amount): + self.bakiye += amount + print(f"{amount} TL yatırıldı. Yeni bakiye: {self.bakiye} TL") + + def money_check(self, amount): + if self.bakiye >= amount: + self.bakiye -= amount + print(f"{amount} TL çekildi. Kalan bakiye: {self.bakiye} TL") + else: + print("Yetersiz bakiye! İşlem gerçekleştirilemedi.") + + def display_balance(self): + print(f"Hesap Numarası: {self.hesap_numarasi} | Güncel Bakiye: {self.bakiye} TL") + + +# Müşteri oluşturma +musteri1 = Hesap("Ahmet", "Yılmaz", "12345678901", "0555 111 22 33", "TR100200300", 500) + +# Müşteri bilgilerini görüntüleme +musteri1.display_information() + +# Hesap işlemleri +musteri1.display_balance() +musteri1.deposit(200) +musteri1.money_check(100) +musteri1.money_check(700) # Yetersiz bakiye durumu +musteri1.display_balance() From f53448a102dc59899e51eba4b6bb254a9586b0f7 Mon Sep 17 00:00:00 2001 From: ali-tevfik Date: Sun, 21 Sep 2025 14:08:08 +0200 Subject: [PATCH 3/4] Create fahri file --- README.md => fahri/README.md | 0 kutuphane.db => fahri/kutuphane.db | Bin kutuphane.json => fahri/kutuphane.json | 0 week4.py => fahri/week4.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename README.md => fahri/README.md (100%) rename kutuphane.db => fahri/kutuphane.db (100%) rename kutuphane.json => fahri/kutuphane.json (100%) rename week4.py => fahri/week4.py (100%) diff --git a/README.md b/fahri/README.md similarity index 100% rename from README.md rename to fahri/README.md diff --git a/kutuphane.db b/fahri/kutuphane.db similarity index 100% rename from kutuphane.db rename to fahri/kutuphane.db diff --git a/kutuphane.json b/fahri/kutuphane.json similarity index 100% rename from kutuphane.json rename to fahri/kutuphane.json diff --git a/week4.py b/fahri/week4.py similarity index 100% rename from week4.py rename to fahri/week4.py From 28da2b0737ea418623d36c2c732335cad90286cd Mon Sep 17 00:00:00 2001 From: ali-tevfik Date: Sun, 21 Sep 2025 14:10:46 +0200 Subject: [PATCH 4/4] Delete dsfile --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0