From 5eb3589ae0684a0f54f5b9350d5af3a5b21cdbdf Mon Sep 17 00:00:00 2001 From: Harriery <98697353+Harriery@users.noreply.github.com> Date: Sat, 28 Dec 2024 12:14:53 +0100 Subject: [PATCH 1/7] team_1 folders --- team_1/haluk/hackerrank.py | 0 team_1/haluk/homework.py | 0 team_1/islam/hackerrank.py | 0 team_1/islam/homework.py | 0 team_1/yasin/hackerrank.py | 0 team_1/yasin/homework.py | 0 team_1/zehra/hackerrank.py | 0 team_1/zehra/homework.py | 0 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 team_1/haluk/hackerrank.py create mode 100644 team_1/haluk/homework.py create mode 100644 team_1/islam/hackerrank.py create mode 100644 team_1/islam/homework.py create mode 100644 team_1/yasin/hackerrank.py create mode 100644 team_1/yasin/homework.py create mode 100644 team_1/zehra/hackerrank.py create mode 100644 team_1/zehra/homework.py diff --git a/team_1/haluk/hackerrank.py b/team_1/haluk/hackerrank.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/haluk/homework.py b/team_1/haluk/homework.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/islam/hackerrank.py b/team_1/islam/hackerrank.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/islam/homework.py b/team_1/islam/homework.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/yasin/hackerrank.py b/team_1/yasin/hackerrank.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/yasin/homework.py b/team_1/yasin/homework.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/zehra/hackerrank.py b/team_1/zehra/hackerrank.py new file mode 100644 index 0000000..e69de29 diff --git a/team_1/zehra/homework.py b/team_1/zehra/homework.py new file mode 100644 index 0000000..e69de29 From 32ae402bad2f0118551afde77bdbfc0926ccca91 Mon Sep 17 00:00:00 2001 From: haluklevent34 Date: Fri, 3 Jan 2025 00:12:14 +0100 Subject: [PATCH 2/7] Update homework.py --- team_1/haluk/homework.py | 196 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/team_1/haluk/homework.py b/team_1/haluk/homework.py index e69de29..070b0a8 100644 --- a/team_1/haluk/homework.py +++ b/team_1/haluk/homework.py @@ -0,0 +1,196 @@ + + + # Question1 + + + +students = { + 'Ahmet Yılmaz': [85, 90, 78], + 'Mehmet Demir': [92, 88, 76], + 'Ayşe Kaya': [78, 89, 95], + 'Zeynep Çelik': [65, 70, 80], + 'Ali Kara': [50, 60, 55], + 'Fatma Yıldız': [88, 85, 90], + 'Murat Aydın': [72, 68, 74], + 'Elif Aksoy': [95, 90, 88], + 'Hakan Öztürk': [45, 50, 55], + 'Canan Taş': [80, 75, 82] +} +print("\n1- Calculate each student's GPA and add it to the dictionary\n2- Find the student with the highest GPA and print it on the screen.\n3- Separate each student's name from their surname and store them in a separate tuple and add them to a list.\n4- Sort the names in alphabetical order and print the sorted list on the screen.\n5- Keep students with a GPA below 70 in a cluster (set).") +while True: + secim = int(input("\nSeçiminizi giriniz: ")) + if secim == 1: + for ogrenci in students: + notlar = students[ogrenci] + notlar.append(sum(notlar)/len(notlar)) + print(students) + + + elif secim == 2: + en_yuksek_ortalama = 0 + en_iyi_ogrenci = "" + + for ogrenci, notlar in students.items(): + ortalama = sum(notlar)//len(notlar) + if ortalama > en_yuksek_ortalama: + en_yuksek_ortalama = ortalama + en_iyi_ogrenci = ogrenci + + print('En basarili ogrenci :', en_iyi_ogrenci ,' - ','GPA :', en_yuksek_ortalama) + + elif secim == 3: + isimler = [] + soyisimler = [] + for ogrenci in students.keys(): + isimler.append(ogrenci.split()[0]) + tupleisimler= tuple(isimler) + for ogrenci in students.keys(): + soyisimler.append(ogrenci.split()[1]) + tuplesoyisimler= tuple(soyisimler) + print(tupleisimler) + print(tuplesoyisimler) + elif secim == 4: + names = [] + for isim in students.keys(): + names.append(isim) + print(sorted(names)) + + + elif secim == 5: + basarisizlar=[] + for ogrenci, notlar in students.items(): + ortalama = sum(notlar) // len(notlar) + if ortalama < 70: + basarisizlar.append(ogrenci) + basarisizlarkumesi = set(basarisizlar) + print(basarisizlarkumesi) + + else: + print('Gecerli bir sayi giriniz :') + + + + + # Question2 + + + + +print('\n1. Film Ekleyin\n2. Filmi Duzenleyin\n3. Koleksiyonu Goruntuleyin\n') +tumfilmler = {} + +while True: + try: + secim1 = int(input("Seciminizi giriniz: ")) + if secim1 == 1: + ad = input('Film adini giriniz : ') + tur = input('Film turunu giriniz : ') + yonetmen = input('Yonetmen adini giriniz : ') + yil = input('Yayin yilini giriniz : ') + yenikayit = {'Film adi': ad, 'Film turu': tur, 'Yonetmen': yonetmen, 'Yayin yili': yil} + tumfilmler[ad] = yenikayit + print("\nFilm başarıyla eklendi!\n") + + elif secim1 == 2: + film_adi = input('Düzenlemek veya silmek istediğiniz filmin adını giriniz: ') + if film_adi in tumfilmler: + print(f"\nMevcut bilgiler: {tumfilmler[film_adi]}") + print('\n1. Filmi Düzenle\n2. Filmi Sil\n') + try: + alt_secim = int(input("Seçiminizi giriniz: ")) + if alt_secim == 1: + tur = input('Yeni film turunu giriniz : ') + yonetmen = input('Yeni yönetmen adını giriniz : ') + yil = input('Yeni yayın yılını giriniz : ') + tumfilmler[film_adi] = {'Film adi': film_adi, 'Film turu': tur, 'Yonetmen': yonetmen, 'Yayin yili': yil} + print("\nFilm başarıyla güncellendi!\n") + elif alt_secim == 2: + del tumfilmler[film_adi] + print(f"\n'{film_adi}' adlı film başarıyla silindi.\n") + else: + print("\nGeçersiz seçim, lütfen tekrar deneyiniz.") + except ValueError: + print("\nLütfen geçerli bir sayı giriniz.") + else: + print("\nFilm bulunamadı.\n") + + elif secim1 == 3: + if not tumfilmler: + print("\nKoleksiyonda film bulunmuyor.\n") + else: + print("\nKoleksiyondaki Filmler:") + for film in tumfilmler.values(): + print(f"- {film}") + + else: + print("\nGeçersiz seçim, tekrar deneyiniz.") + except ValueError: + print("\nLütfen geçerli bir sayı giriniz.") + + devam = input("\nDevam etmek istiyor musunuz? (e/h): ") + if devam.lower() != 'e': + print("\nProgramdan çıkılıyor...") + break + + + #Question3 + + + +print('\n1. Müşteri Ekleyin\n2. Müşteriyi Düzenleyin\n3. Müşteri Silin\n4. Müşteri Listesini Görüntüleyin\n') +musteriler = {} +id_counter = 1 + +while True: + try: + secim = int(input("Seçiminizi giriniz: ")) + if secim == 1: + ad = input('Müşteri adı: ') + soyad = input('Müşteri soyadı: ') + telefon = input('Telefon numarası: ') + email = input('E-posta adresi: ') + yeni_musteri = {'ID': id_counter, 'Ad': ad, 'Soyad': soyad, 'Telefon': telefon, 'Email': email} + musteriler[id_counter] = yeni_musteri + print(f"\nMüşteri başarıyla eklendi! Müşteri ID: {id_counter}\n") + id_counter += 1 + elif secim == 2: + try: + musteri_id = int(input('Düzenlemek istediğiniz müşterinin ID numarasını giriniz: ')) + if musteri_id in musteriler: + print(f"\nMevcut bilgiler: {musteriler[musteri_id]}") + ad = input('Yeni müşteri adı: ') + soyad = input('Yeni müşteri soyadı: ') + telefon = input('Yeni telefon numarası: ') + email = input('Yeni e-posta adresi: ') + musteriler[musteri_id] = {'ID': musteri_id, 'Ad': ad, 'Soyad': soyad, 'Telefon': telefon, 'Email': email} + print("\nMüşteri başarıyla güncellendi!\n") + else: + print("\nGirilen ID ile eşleşen müşteri bulunamadı.\n") + except ValueError: + print("\nLütfen geçerli bir sayı giriniz.") + elif secim == 3: + try: + musteri_id = int(input('Silmek istediğiniz müşterinin ID numarasını giriniz: ')) + if musteri_id in musteriler: + del musteriler[musteri_id] + print(f"\nMüşteri başarıyla silindi (ID: {musteri_id}).\n") + else: + print("\nGirilen ID ile eşleşen müşteri bulunamadı.\n") + except ValueError: + print("\nLütfen geçerli bir sayı giriniz.") + elif secim == 4: + if not musteriler: + print("\nSistemde kayıtlı müşteri bulunmuyor.\n") + else: + print("\nKayıtlı Müşteriler:") + for musteri in musteriler.values(): + print(f"- ID: {musteri['ID']}, Ad: {musteri['Ad']}, Soyad: {musteri['Soyad']}, Telefon: {musteri['Telefon']}, Email: {musteri['Email']}") + else: + print("\nGeçersiz seçim, tekrar deneyiniz.") + except ValueError: + print("\nLütfen geçerli bir sayı giriniz.") + devam = input("\nDevam etmek istiyor musunuz? (e/h): ") + if devam.lower() != 'e': + print("\nProgramdan çıkılıyor...") + break + From 41d949370ac65f10d6ab33538483281ae9ea3513 Mon Sep 17 00:00:00 2001 From: okayzhr Date: Fri, 3 Jan 2025 19:29:15 +0100 Subject: [PATCH 3/7] Update hackerrank.py --- team_1/zehra/hackerrank.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/team_1/zehra/hackerrank.py b/team_1/zehra/hackerrank.py index e69de29..b9316cd 100644 --- a/team_1/zehra/hackerrank.py +++ b/team_1/zehra/hackerrank.py @@ -0,0 +1,8 @@ +#https://www.hackerrank.com/challenges/list-comprehensions/problem +if __name__ == '__main__': + x = int(input()) + y = int(input()) + z = int(input()) + n = int(input()) + result = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n] +print(result) From ec4806463261a660bcbe397d98753c6aff01d8ab Mon Sep 17 00:00:00 2001 From: okayzhr Date: Fri, 3 Jan 2025 19:29:21 +0100 Subject: [PATCH 4/7] Update homework.py --- team_1/zehra/homework.py | 134 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/team_1/zehra/homework.py b/team_1/zehra/homework.py index e69de29..74dfb82 100644 --- a/team_1/zehra/homework.py +++ b/team_1/zehra/homework.py @@ -0,0 +1,134 @@ +#Question1: Student Grades Processing +#1-Calculate each student's GPA and add it to the dictionary. +from ntpath import split + +students={ + "Ahmet Yilmaz": [85,90,92], + "Mehmet Demir": [92,88,60], + "Ayse Kaya": [78,89,91], + "Zeynep Celik": [65,70,81], + "Ali Kara": [50,60,55], + "Hakan Ozturk": [45,50,55] +} +#2-Find the student with the highest GPA and print it on the screen. + +for student, grades in students.items(): + gpa=sum(grades)/len(grades) + students[student].append(gpa) +max_student=[] +maxgpa=0 +for student, grades in students.items(): + gpa=grades[-1] + if gpa>maxgpa: + maxgpa=gpa + max_student=student + print(max_student) + +#3- Separate each student's name from their surname and store them in a separate tuple and add them to a list. + +namelist=[] +for student in students.keys(): + a=student.split() + b=(a[0],a[1]) + namelist.append(b) +print(namelist) + +#4-Sort the names in alphabetical order and print the sorted list on the screen. + +sorted_list=sorted(namelist) +print(sorted_list) + +#5-Keep students with a GPA below 70 in a cluster (set). + +low_scores=set() + +for student, grades in students.items(): + gpa=sum(grades)/len(grades) + if gpa<70: + low_scores.add(student) + print(low_scores) + +###################################################################################### + +#Question 3: Customer Management System +musteriKoleksiyonu={} + +musteriKoleksiyonu[1]={ + "musteriAdi":"ali", + "musteriSoyadi":"ak", + "musteriTelefonu":"0623162354", + "musteriMail":"aliak@gmail.com"} + + +while True: + print("Yeni musteri eklemek icin 1 yaziniz") + print("Musteri bilgilerini guncellemek icin 2 yaziniz") + print("musteri silmek icin 3 yaziniz") + print("Tum musterileri listelemek icin 4 yaziniz") + print("cikis yapmak icin 5 yaziniz") + + secenek=input("bir rakam giriniz") + if secenek == "1": + musteri_adi=input("Musteri adi:") + musteri_soyadi=input("Musteri Soyadi:") + musteri_tel=input("Musteri Telefonu:") + musteri_mail=input("musteri mail:") + + musteri_id=len(musteriKoleksiyonu)+1 + musteriKoleksiyonu[musteri_id]={ + "musteriAdi": musteri_adi, + "musteriSoyadi": musteri_soyadi, + "musteriTelefonu": musteri_tel, + "musteriMail": musteri_mail + } + print("yeni musteri basari ile eklendi") + + elif secenek == "2": + musteri_id=int(input("guncellemek istediginiz bilginin numarasini giriniz:")) + if musteri_id in musteriKoleksiyonu: + print("Adi guncellemek icin 1") + print("Soyadi guncelemek icin 2") + print("Telefon numarasini guncellemek icin 3") + print("maili guncellemek icin 4") + + secimguncelleme=input("guncellemek istedigini verinin numarasini giriniz:") + if secimguncelleme == "1": + yeni_ad=input("yeni adi giriniz:") + musteriKoleksiyonu[musteri_id]["musteriAdi"]=yeni_ad + elif secimguncelleme == "2": + yeni_soyad=input("yeni soyadi giriniz:") + musteriKoleksiyonu[musteri_id]["musteriSoyadi"]=yeni_soyad + elif secimguncelleme=="3": + yeni_tel=input("yeni tel no giriniz:") + musteriKoleksiyonu[musteri_id]["musteriTelefonu"]=yeni_tel + elif secimguncelleme=="4": + yeni_mail=input("yeni mail adresini giriniz") + musteriKoleksiyonu[musteri_id]["musteriMail"]=yeni_mail + else: + print("yanlis giris yaptiniz") + elif secenek == "3": + musteri_id = int(input("Silmek istediğiniz müşterinin ID'sini giriniz: ")) + if musteri_id in musteriKoleksiyonu: + del musteriKoleksiyonu[musteri_id] + print("Müşteri ID",musteri_id,"başarıyla silindi.") + + elif secenek == "4": + if musteriKoleksiyonu: + print("\nTüm Müşteri Listesi:") + for id, musteri in musteriKoleksiyonu.items(): + print( + f"ID: {id}, Ad: {musteri['musteriAdi']}, Soyad: {musteri['musteriSoyadi']}, Tel: {musteri['musteriTelefonu']}, Mail: {musteri['musteriMail']}") + print("------------------------") + else: + print("Hiç müşteri kaydı bulunmamaktadır.") + + elif secenek == "5": + print("cikis yapiliyor") + break + + else: + print("gecersiz rakam yazdiniz lutfen 1 ile 5 arasi bir numara seciniz.") + +############################################################################################## + + From 1617bc85385af3c1fcb9e6e82492ad41173a0bdb Mon Sep 17 00:00:00 2001 From: okayzhr Date: Fri, 3 Jan 2025 19:43:50 +0100 Subject: [PATCH 5/7] Update hackerrank.py --- team_1/zehra/hackerrank.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/team_1/zehra/hackerrank.py b/team_1/zehra/hackerrank.py index b9316cd..66c40d7 100644 --- a/team_1/zehra/hackerrank.py +++ b/team_1/zehra/hackerrank.py @@ -4,5 +4,3 @@ y = int(input()) z = int(input()) n = int(input()) - result = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n] -print(result) From 282819de02ac3127eb354e3cfc4dda8d82ee1166 Mon Sep 17 00:00:00 2001 From: Islam Kavas Date: Fri, 3 Jan 2025 21:09:41 +0100 Subject: [PATCH 6/7] Week_2 --- team_1/islam/hackerrank.py | 13 ++ team_1/islam/homework.py | 235 +++++++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) diff --git a/team_1/islam/hackerrank.py b/team_1/islam/hackerrank.py index e69de29..2e23819 100644 --- a/team_1/islam/hackerrank.py +++ b/team_1/islam/hackerrank.py @@ -0,0 +1,13 @@ +''' +#Hackerrank Solution 1 +print( [ [i, j, k] for i in list(range(0, x+1)) for j in list(range(0, y+1)) for k in list(range(0, z+1)) if i + j + k != n] ) + +#Hackerrank Solution 2 + + n = int(input()) + integer_list = map(int, input().split()) + + t = tuple(integer_list) + print(hash(t)) +''' + diff --git a/team_1/islam/homework.py b/team_1/islam/homework.py index e69de29..4b678ed 100644 --- a/team_1/islam/homework.py +++ b/team_1/islam/homework.py @@ -0,0 +1,235 @@ +''' +#Question1: Student Grades Processing + +#Listing a group of students and their grades + +print("Welcome to Student Grades Processing Program") +students_grades = { + 'Cem Yakışıklı' : [50, 45, 70], + 'Ahmet Demir' : [74, 87, 56], + 'Ahmet Türkan' : [34, 70, 100], + 'Yusuf Akbaba' : [20, 100, 79], + 'Musa Kılıç' : [67, 34, 56], + 'Sinem Çelik' : [45, 40, 50], + 'Bağrım Bakır' : [90, 80, 95], + 'Çiğdem Çıldır' : [78, 44, 87], + 'Sezai Serkeş' : [45, 73, 89], + 'Yunus Kandır' : [87, 45, 90] +} + +#Calculate GPA for each student +for grades in students_grades.values(): + gpa = sum(grades)/len(grades) #GPA calculated as the average of grades + grades.append(gpa) #GPA add to the end of the grades + +#Print each students names, grades and GPA +for student, grades in students_grades.items(): + print(f"\n{student}: {grades[:-1]}, GPA: {grades[-1]:.2f} ") + + +#Find the highest GPA and its owner +top_student = None +highest_gpa = 0 + +for student, grades in students_grades.items(): + + if grades[-1] > highest_gpa: + highest_gpa = grades[-1] + top_student = student + + + +#Print the students name and GPA having the highest GPA + +print(f"\nThe student having the highest GPA is {top_student} with a GPA of {highest_gpa:.2f}") + +# List to store tuples of first and last names +names_list = [] +for student in students_grades.keys(): + student_name = student.split() + first_name, last_name = student_name[0], student_name[1] + names_list.append((first_name, last_name)) + +print("\nList of names (First, Last):", names_list) + +#Sort the names in alphabetical order and print the sorted list on the screen. +names_list.sort() + +print(f"\nList of sorted names: {names_list}") + +#Keep students with a GPA below 70 in a cluster (set). + +students_below_70 = set() + +for student, grades in students_grades.items(): + if grades[-1] < 70: + students_below_70.add(student) + +print(f"\nStudents with GPA below 70: {students_below_70}") +''' + + + + +'''print("Film Library Management System\n") + +film_pool = {} + +while True: + + print("1. Add Movie") + print("2. Edit Movie") + print("3. Delete Movie") + print("4. View Collection") + print("5. Save and Exit") + choice = input("Enter your choice (1/2/3/4/5): ") + + #Add Movie + + if choice == '1': + + film_name = input("Please enter the name of the movie: ") + film_director = input("Please enter the director of the movie: ") + film_year = input("Please enter the release year of the movie: ") + film_genre = input("Please enter the genre of the movie: ") + film_pool[film_name] = { + 'Director' : film_director, + 'Release Year' : film_year, + 'Genre' : film_genre + + } + + print(f"Movie '{film_name}' added successfully.") + + #Edit Movie + + elif choice == '2': + film_name = input("Please enter the name you want to edit: ") + + if film_name in film_pool: + print("What would you like to edit?") + edit_choice = input("To edit director please press 1 \nTo edit release year press 2 \nTo edit genre press 3: ") + if edit_choice == '1': + film_pool['Director'] = input("Please enter the new name: ") + elif edit_choice == '2': + film_pool['Release Year'] = input("Please enter the new year: ") + elif edit_choice == '3': + film_pool['Genre'] = input("Please enter the new genre: ") + + else: + print("Invalid choice.") + + print(f"You have edited {film_name} successfully.") + + else: + print("Tha name you entered could not be found on the list.") + + + #Delete Movie + + elif choice == '3': + film_name = input("Please enter the movie to be deleted: ") + if film_name in film_pool: + del film_pool[film_name] + print(f"{film_name} is deleted from the list") + + else: + print("The name you entered could not be found.") + + #View Collection + + elif choice == '4': + if not film_pool: + print("No movies in the list yet.") + + else: + print("What do you want to view?") + print("1. View all movies.") + print("2. Filte by director.") + print("3. Filter by release date.") + print("4. Filter by genre.") + + view_choice = input("Please enter your choice number: ") + if view_choice == '1': + for name, details in film_pool.items(): + print("Name : {film_name}, Director: {details['Director']}, Release Year: {details['Release Year']}, Genre: {details['Genre']}") + + elif choice == '2': + director_filter = input("Enter director to filter by: ") + for name, details in film_pool.items(): + + if details['Director'] == director_filter: + print(f"Name: {name}, Director: {details['Director']}, Release Year: {details['Release Year']}, Genre: {details['Genre']}") + + + elif choice == '3': + release_filter = input("Enter a year to filter by: ") + for name, details in film_pool.items(): + + if details['Release Year'] == release_filter: + print(f"Name: {name}, Director: {details['Director']}, Release Year: {details['Release Year']}, Genre: {details['Genre']}") + + elif choice == '4': + genre_filter = input("Enter a genre to filter by: ") + for name, details in film_pool.items(): + + if details['Genre'] == genre_filter: + print(f"Name: {name}, Director: {details['Director']}, Release Year: {details['Release Year']}, Genre: {details['Genre']}") + else: + print("Invalid choice.") +''' + + +print("Customer Management System\n") + +customer_pool = {} + +customer_id = 100 + +while True: + + print("1. Add Customer") + print("2. Updating Customer Information") + print("3. Delete Customer") + print("4. List All Customers ") + print("5. Check Out") + choice = input("Enter your choice (1/2/3/4/5): ") + + if choice == '1': + customer_name = input("Please enter the customer name: ") + customer_phone = input("Please enter the customer's phone number: ") + customer_email = input("Please enter the customer's email: ") + customer_id +=1 + customer_pool[customer_id] = { + 'Name' : customer_name, + 'Phone' : customer_phone, + 'Email' : customer_email, + } + print(f"{customer_name} is registered with the customer id: {customer_id}.") + + + + + + + + + + + + + + + + + + + + + + + + + + + From 206bfd745cf52aee73f9fc11077d296308ce346c Mon Sep 17 00:00:00 2001 From: Harriery <98697353+Harriery@users.noreply.github.com> Date: Fri, 3 Jan 2025 21:54:16 +0100 Subject: [PATCH 7/7] week_2 homework completed --- team_1/yasin/{homework.py => customer.json} | 0 team_1/yasin/deneme.py | 50 +++++ team_1/yasin/hackerrank.py | 25 +++ team_1/yasin/movies.json | 47 +++++ team_1/yasin/question_1.py | 100 ++++++++++ team_1/yasin/question_2.py | 211 ++++++++++++++++++++ team_1/yasin/question_3.py | 112 +++++++++++ 7 files changed, 545 insertions(+) rename team_1/yasin/{homework.py => customer.json} (100%) create mode 100644 team_1/yasin/deneme.py create mode 100644 team_1/yasin/movies.json create mode 100644 team_1/yasin/question_1.py create mode 100644 team_1/yasin/question_2.py create mode 100644 team_1/yasin/question_3.py diff --git a/team_1/yasin/homework.py b/team_1/yasin/customer.json similarity index 100% rename from team_1/yasin/homework.py rename to team_1/yasin/customer.json diff --git a/team_1/yasin/deneme.py b/team_1/yasin/deneme.py new file mode 100644 index 0000000..bb74f58 --- /dev/null +++ b/team_1/yasin/deneme.py @@ -0,0 +1,50 @@ +import json +movie_liste = { + 'The Lord of The Rings - The Fellowship of the Rings': { + 'Movie Year': 2001, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Two Towers': { + 'Movie Year': 2002, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Return of the King': { + 'Movie Year': 2003, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'Kingdom of Heaven': { + 'Movie Year': 2005, + 'Director': 'Ridley Scott', + 'Movie Genre': 'Action-History-War' + }, + 'The Green Mile': { + 'Movie Year': 1999, + 'Director': 'Frank Darabont', + 'Movie Genre': 'Drama-Fantasy' + }, + 'Saving Private Ryan': { + 'Movie Year': 1998, + 'Director': 'Steven Spielberg', + 'Movie Genre': 'History-War' + }, + 'Harry Potter and the Prisoner of Azkaban': { + 'Movie Year': 2004, + 'Director': 'Alfonso Cuaron', + 'Movie Genre': 'Fantasy-Adventure' + }, + 'The Curious Case of Benjamin Button': { + 'Movie Year': 2008, + 'Director': 'David Fincher', + 'Movie Genre': 'Drama' + }, + 'Pearl Harbor': { + 'Movie Year': 2001, + 'Director': 'Michael Bay', + 'Movie Genre': 'War-Drama' + } +} +with open("movies.json", "w") as file: + json.dump(movie_liste, file, indent=4) diff --git a/team_1/yasin/hackerrank.py b/team_1/yasin/hackerrank.py index e69de29..0f674b5 100644 --- a/team_1/yasin/hackerrank.py +++ b/team_1/yasin/hackerrank.py @@ -0,0 +1,25 @@ +#1- https://www.hackerrank.com/challenges/list-comprehensions/problem +# Giriş: dört tam sayı +x = int(input("x değeri: ")) +y = int(input("y değeri: ")) +z = int(input("z değeri: ")) +n = int(input("n değeri: ")) + +# Tüm permütasyonları oluşturuyoruz +permutasyonlar = [[i, j, k] for i in range(x+1) for j in range(y+1) for k in range(z+1)] + +# Toplamı n'ye eşit olmayanları filtreliyoruz +sonuc = [perm for perm in permutasyonlar if sum(perm) != n] + +# Sonucu yazdırıyoruz +print(sonuc) + +#2- https://www.hackerrank.com/challenges/python-tuples/problem +# Girdi olarak alınan sayılar +n = int(input()) # Tuple içindeki eleman sayısı +elemanlar = tuple(map(int, input().split())) # Tuple'a dönüştürülen sayılar + +# Hash fonksiyonunu kullanarak tuple'ın hash değerini hesapla +print(hash(elemanlar)) + +#3- \ No newline at end of file diff --git a/team_1/yasin/movies.json b/team_1/yasin/movies.json new file mode 100644 index 0000000..dce146f --- /dev/null +++ b/team_1/yasin/movies.json @@ -0,0 +1,47 @@ +{ + "The Lord of The Rings - The Fellowship of the Rings": { + "Movie Year": 2001, + "Director": "Peter Jackson", + "Movie Genre": "Adventure" + }, + "The Lord of The Rings - The Two Towers": { + "Movie Year": 2002, + "Director": "Peter Jackson", + "Movie Genre": "Adventure" + }, + "The Lord of The Rings - The Return of the King": { + "Movie Year": 2003, + "Director": "Peter Jackson", + "Movie Genre": "Adventure" + }, + "Kingdom of Heaven": { + "Movie Year": 2005, + "Director": "Ridley Scott", + "Movie Genre": "Action-History-War" + }, + "The Green Mile": { + "Movie Year": 1999, + "Director": "Frank Darabont", + "Movie Genre": "Drama-Fantasy" + }, + "Saving Private Ryan": { + "Movie Year": 1998, + "Director": "Steven Spielberg", + "Movie Genre": "History-War" + }, + "Harry Potter and the Prisoner of Azkaban": { + "Movie Year": 2004, + "Director": "Alfonso Cuaron", + "Movie Genre": "Fantasy-Adventure" + }, + "The Curious Case of Benjamin Button": { + "Movie Year": 2008, + "Director": "David Fincher", + "Movie Genre": "Drama" + }, + "Pearl Harbor": { + "Movie Year": 2001, + "Director": "Michael Bay", + "Movie Genre": "War-Drama" + } +} \ No newline at end of file diff --git a/team_1/yasin/question_1.py b/team_1/yasin/question_1.py new file mode 100644 index 0000000..c52f984 --- /dev/null +++ b/team_1/yasin/question_1.py @@ -0,0 +1,100 @@ +# Question1: Student Grades Processing +students = { + "Ahmet Yilmaz" : [85, 90, 78], + "Mehmet Demir" : [92, 88, 76], + "Ayse Kaya" : [78, 89, 95], + "Zeynep Celik" : [65, 70, 80], + "Ali Kara" : [50, 60, 55], + "Fatma Yildiz" : [88, 85, 90], + "Mutrat Aydin" : [72, 68, 74], + "Elif Aksoy" : [95, 90, 88], + "Hakan Ozturk" : [45, 50, 55], + "Canan Tas" : [80, 75, 82], +} + +# 1-Calculate each student's GPA and add it to the dictionary. + +average_notes = {} + +for student, notes in students.items(): + average = sum(notes) // len(notes) + average_notes[student] = average +print(average_notes) +# average_notes ={ +# 'Ahmet Yilmaz': 84, +# 'Mehmet Demir': 85, +# 'Ayse Kaya': 87, +# 'Zeynep Celik': 71, +# 'Ali Kara': 55, +# 'Fatma Yildiz': 87, +# 'Mutrat Aydin': 71, +# 'Elif Aksoy': 91, +# 'Hakan Ozturk': 50, +# 'Canan Tas': 79} + +#2-Find the student with the highest GPA and print it on the screen. + +student_max_note = max(average_notes, key =average_notes.get) # average_notes.get("Ali") → 90, average_notes.get("Ayşe") → 94, average_notes.get("Mehmet") → 82 +print(student_max_note, average_notes[student_max_note]) + +# max() max() fonksiyonu sözlükteki anahtarları alır: "Ali", "Ayşe", "Mehmet". +# Her anahtar için average_notes.get() fonksiyonu çalıştırılır: +# "Ali" için average_notes.get("Ali") → 90 +# "Ayşe" için average_notes.get("Ayşe") → 94 +# "Mehmet" için average_notes.get("Mehmet") → 82 +# max() fonksiyonu bu değerleri karşılaştırarak en büyük değeri bulur: 94. +# max() fonksiyonu, en büyük değeri veren anahtarın adını döndürür: "Ayşe". +# student_max_note = Elif Aksoy + +# 3- Separate each student's name from their surname and store them in a separate tuple and add them to a list. + +new_students ={} + +for student, notes in students.items(): + first_name = student.split()[0] # Her bir ogrencinin adini soyadindan split metodu ile ayirdik ve sadece adini aldik. + new_students[first_name] = notes + +print(new_students) +# {'Ahmet': [85, 90, 78], +# 'Mehmet': [92, 88, 76], +# 'Ayse': [78, 89, 95], +# 'Zeynep': [65, 70, 80], +# 'Ali': [50, 60, 55], +# 'Fatma': [88, 85, 90], +# 'Mutrat': [72, 68, 74], +# 'Elif': [95, 90, 88], +# 'Hakan': [45, 50, 55], +# 'Canan': [80, 75, 82]} + +#4-Sort the names in alphabetical order and print the sorted list on the screen. +alphabetical_dictionary ={} +sorted_students = sorted(new_students.items()) # ogrenciler aslari siralandi notlariyla birlikte. + +for student, note in sorted_students: # for ile yeni sozluge atildilar. + alphabetical_dictionary[student] = note + +print(alphabetical_dictionary) + +#{'Ahmet': [85, 90, 78], +# 'Ali': [50, 60, 55], +# 'Ayse': [78, 89, 95], +# 'Canan': [80, 75, 82], +# 'Elif': [95, 90, 88], +# 'Fatma': [88, 85, 90], +# 'Hakan': [45, 50, 55], +# 'Mehmet': [92, 88, 76], +# 'Mutrat': [72, 68, 74], +# 'Zeynep': [65, 70, 80]} + +# 5-Keep students with a GPA below 70 in a cluster (set). + +below_70 = {} + +for student, note in average_notes.items(): + if note <= 70: + below_70[student] = note + +print(below_70) + +#{'Ali Kara': 55, +# 'Hakan Ozturk': 50} \ No newline at end of file diff --git a/team_1/yasin/question_2.py b/team_1/yasin/question_2.py new file mode 100644 index 0000000..6f9a67f --- /dev/null +++ b/team_1/yasin/question_2.py @@ -0,0 +1,211 @@ +#Project Description: This project aims to create an application that will help the user manage their movie collection. +# Users can add, edit, delete movies and view their collection. + +#Data Structures Used: Dictionaries (to store movies and related information), lists (to display movie collection) + +# 1-Create a movie data by taking information such as movie name, director, release year and genre from the user and store it in a dictionary. + +def create_movie_list(): + movie ={} + + for i in range(10): + movie_name = input(f"{i+1}, Enter a nameof Movie :") + movie_year = int(input("Enter Year of Release :")) + director = input("Enter a director of Movie :") + movie_genre = input("Enter a Genre of Movie :") + + movie_data ={ + "Movie Name" : movie_name, + "Movie Year" : movie_year, + "Director" : director, + "Movie Genre" : movie_genre + + } + + movie.append(movie_data) + return movie + +movie_list = create_movie_list() +print(movie_list) + +#[ +# {'Movie Name': 'The Lord of The Rings - The Fellowship of the Rings', 'Movie Year': 2001, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'}, +# {'Movie Name': 'The Lord of The Rings - The Two Towers', 'Movie Year': 2002, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'}, +# {'Movie Name': 'The Lord of The Rings - The Return of the King', 'Movie Year': 2003, 'Director': 'Adventure', 'Movie Genre': 'Adventure'}, +# {'Movie Name': 'Hobbit', 'Movie Year': 2012, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'}, +# {'Movie Name': 'Kingdom of Heaven', 'Movie Year': 2005, 'Director': 'Ridley Schott', 'Movie Genre': 'Action-History-War'}, +# {'Movie Name': 'The Green Mile', 'Movie Year': 1999, 'Director': 'Frank Darabont', 'Movie Genre': 'Dram-Fantastic'}, +# {'Movie Name': 'Saving Private Ryan', 'Movie Year': 1998, 'Director': 'Steven Spielberg', 'Movie Genre': 'History-War'}, +# {'Movie Name': 'Harry Potter and the Prisoner of Azkaban', 'Movie Year': 2004, 'Director': 'Alfonso Cuaron', 'Movie Genre': 'Fantastic-Adventure'}, +# {'Movie Name': 'The Curious Case of Benjamin Button', 'Movie Year': 2008, 'Director': 'David Fincher', 'Movie Genre': 'Dram'}, +# {'Movie Name': 'Pearl Harbor', 'Movie Year': 2001, 'Director': 'Michael Bay', 'Movie Genre': 'War-Drama'} +#] +film_sozlugu ={} +def film_ekle(film_adı, yil, tur, puan): + film_sozlugu[film_adı] = {"yil": yil, "tur": tur, "puan": puan} + +film_ekle("Kabadayi", 2015, "gerilim", 7.1) +print(film_sozlugu) + +#****************************************************************** +#2- Give the user the option to edit or delete a movie. (For this, a suitable function must be written for whatever data they want to change about the movie.) +movie_list = { + "Inception": { + "Movie Name": "Inception", + "Movie Year": 2010, + "Director": "Christopher Nolan", + "Movie Genre": "Sci-Fi" + }, + "Avatar": { + "Movie Name": "Avatar", + "Movie Year": 2009, + "Director": "James Cameron", + "Movie Genre": "Adventure" + } +} + + + +def del_movie(movie_name): + if movie_name in movie_list: + del movie_list[movie_name] + +def edit_movie(movie_name, new_movie_name= None, new_year=None, new_director=None, new_genre=None): + if movie_name in movie_list: + if new_movie_name: + movie_list[movie_name]["Movie Name" ] = new_movie_name + + if new_year: + movie_list[movie_name]["Movie Year" ] = new_year + + if new_director: + movie_list[movie_name]["Director" ] = new_director + + if new_year: + movie_list[movie_name]["Movie Genre" ] = new_genre + +edit_movie("Avatar", new_movie_name="Avatar: Special Edition") # fonk calistimak icin +edit_movie("Inception", new_year=2012, new_genre="Thriller") # fonk calistimak icin + +#************************************************************************************************ +#3-Allow the user to view their collection. List all movies or filter by criteria such as genre or year of release. + +movie_liste = { + 'The Lord of The Rings - The Fellowship of the Rings': { + 'Movie Year': 2001, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Two Towers': { + 'Movie Year': 2002, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Return of the King': { + 'Movie Year': 2003, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'Kingdom of Heaven': { + 'Movie Year': 2005, + 'Director': 'Ridley Scott', + 'Movie Genre': 'Action-History-War' + }, + 'The Green Mile': { + 'Movie Year': 1999, + 'Director': 'Frank Darabont', + 'Movie Genre': 'Drama-Fantasy' + }, + 'Saving Private Ryan': { + 'Movie Year': 1998, + 'Director': 'Steven Spielberg', + 'Movie Genre': 'History-War' + }, + 'Harry Potter and the Prisoner of Azkaban': { + 'Movie Year': 2004, + 'Director': 'Alfonso Cuaron', + 'Movie Genre': 'Fantasy-Adventure' + }, + 'The Curious Case of Benjamin Button': { + 'Movie Year': 2008, + 'Director': 'David Fincher', + 'Movie Genre': 'Drama' + }, + 'Pearl Harbor': { + 'Movie Year': 2001, + 'Director': 'Michael Bay', + 'Movie Genre': 'War-Drama' + } +} + +def filter_movie(movie_liste, criteria, value): + result =[] + for movie, values in movie_liste.items(): + if criteria == "Movie Year" and values["Movie Year"] == value: # İlk döngüde: film = "Inception", detaylar = {"yil": 2010, "tur": "Bilim Kurgu", "puan": 8.8} + result.append(movie) + if criteria == "Movie Year" and values["Movie Year"] == value: + result.append((movie, values)) + if criteria == "Movie Genre" and values["Movie Genre"] == value: + result.append((movie, values)) + + return result + + #filter_movie(movie_liste, criteria, value) +filtered_movies = filter_movie(movie_liste, "Movie Genre", "Adventure") +print(filtered_movies) + +#[('The Lord of The Rings - The Fellowship of the Rings', {'Movie Year': 2001, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'}), +# ('The Lord of The Rings - The Two Towers', {'Movie Year': 2002, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'}), +# ('The Lord of The Rings - The Return of the King', {'Movie Year': 2003, 'Director': 'Peter Jackson', 'Movie Genre': 'Adventure'})] + +#4-Save the movie data in a file and restore this data when you start the program. +import json +movie_liste = { + 'The Lord of The Rings - The Fellowship of the Rings': { + 'Movie Year': 2001, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Two Towers': { + 'Movie Year': 2002, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'The Lord of The Rings - The Return of the King': { + 'Movie Year': 2003, + 'Director': 'Peter Jackson', + 'Movie Genre': 'Adventure' + }, + 'Kingdom of Heaven': { + 'Movie Year': 2005, + 'Director': 'Ridley Scott', + 'Movie Genre': 'Action-History-War' + }, + 'The Green Mile': { + 'Movie Year': 1999, + 'Director': 'Frank Darabont', + 'Movie Genre': 'Drama-Fantasy' + }, + 'Saving Private Ryan': { + 'Movie Year': 1998, + 'Director': 'Steven Spielberg', + 'Movie Genre': 'History-War' + }, + 'Harry Potter and the Prisoner of Azkaban': { + 'Movie Year': 2004, + 'Director': 'Alfonso Cuaron', + 'Movie Genre': 'Fantasy-Adventure' + }, + 'The Curious Case of Benjamin Button': { + 'Movie Year': 2008, + 'Director': 'David Fincher', + 'Movie Genre': 'Drama' + }, + 'Pearl Harbor': { + 'Movie Year': 2001, + 'Director': 'Michael Bay', + 'Movie Genre': 'War-Drama' + } +} +with open("c:/Users/harri/Desktop/Python_Modul_Week_2/team_1/yasin/my_dictionary.json", "w") as file: + json.dump(movie_liste, file, indent=4) diff --git a/team_1/yasin/question_3.py b/team_1/yasin/question_3.py new file mode 100644 index 0000000..3850a42 --- /dev/null +++ b/team_1/yasin/question_3.py @@ -0,0 +1,112 @@ +import json + +# Dosya yolu +json_dosyasi = "customer.json" + +# Müşteri ID sayacı +id_sayaci = 1 + +# JSON dosyasını yükleme veya yeni bir dosya oluşturma +def dosya_yukle(): + try: + with open(json_dosyasi, "r") as file: + return json.load(file) + except FileNotFoundError: + return {} + +# JSON dosyasını kaydetme +def dosya_kaydet(data): + with open(json_dosyasi, "w") as file: + json.dump(data, file, indent=4) + +# Yeni müşteri ekleme +def musteri_ekle(): + global id_sayaci + musteri_adi_soyadi = input("Müşteri Adı Soyadı: ") + telefon = input("Telefon: ") + email = input("Email: ") + + # Dosyayı yükle + musteri_liste = dosya_yukle() + + # Yeni ID oluştur + yeni_id = str(id_sayaci) + id_sayaci += 1 # ID sayacını bir artır + + # Müşteri bilgilerini listeye ekle + musteri_liste[yeni_id] = {"ad_soyad": musteri_adi_soyadi, "telefon": telefon, "email": email} + + # Dosyayı kaydet + dosya_kaydet(musteri_liste) + print(f"{musteri_adi_soyadi} başarıyla eklendi! (Müşteri ID: {yeni_id})") + +# Müşteri bilgilerini düzenleme +def musteri_duzenle(): + musteri_liste = dosya_yukle() + musteri_id = input("Düzenlemek istediğiniz müşteri ID'si: ") + + if musteri_id in musteri_liste: + print(f"Mevcut Bilgiler: Ad Soyad: {musteri_liste[musteri_id]['ad_soyad']}, Telefon: {musteri_liste[musteri_id]['telefon']}, Email: {musteri_liste[musteri_id]['email']}") + + yeni_ad_soyad = input("Yeni Ad Soyad (değiştirmeyecekseniz boş bırakın): ") + yeni_telefon = input("Yeni Telefon (değiştirmeyecekseniz boş bırakın): ") + yeni_email = input("Yeni Email (değiştirmeyecekseniz boş bırakın): ") + + if yeni_ad_soyad: + musteri_liste[musteri_id]["ad_soyad"] = yeni_ad_soyad + if yeni_telefon: + musteri_liste[musteri_id]["telefon"] = yeni_telefon + if yeni_email: + musteri_liste[musteri_id]["email"] = yeni_email + + dosya_kaydet(musteri_liste) + print(f"Müşteri ID {musteri_id} başarıyla güncellendi!") + else: + print("Bu ID'ye sahip bir müşteri bulunamadı.") + +# Müşteri silme +def musteri_sil(): + musteri_liste = dosya_yukle() + musteri_id = input("Silmek istediğiniz müşteri ID'si: ") + + if musteri_id in musteri_liste: + del musteri_liste[musteri_id] + dosya_kaydet(musteri_liste) + print(f"Müşteri ID {musteri_id} başarıyla silindi!") + else: + print("Bu ID'ye sahip bir müşteri bulunamadı.") + +# Tüm müşterileri listeleme +def musterileri_goruntule(): + musteri_liste = dosya_yukle() + if musteri_liste: + print("\nTüm Müşteriler:") + for musteri_id, bilgiler in musteri_liste.items(): + print(f"ID: {musteri_id} - Ad Soyad: {bilgiler['ad_soyad']}, Telefon: {bilgiler['telefon']}, Email: {bilgiler['email']}") + else: + print("Hiç müşteri bulunamadı.") + +# Ana menü +while True: + print("\nİşlem Menüsü:") + print("1- Yeni Müşteri Ekle") + print("2- Müşteri Bilgilerini Düzenle") + print("3- Müşteri Sil") + print("4- Tüm Müşterileri Görüntüle") + print("5- Çıkış") + + secim = input("Bir işlem seçiniz: ") + + if secim == "1": + musteri_ekle() + elif secim == "2": + musteri_duzenle() + elif secim == "3": + musteri_sil() + elif secim == "4": + musterileri_goruntule() + elif secim == "5": + print("Çıkış yapılıyor...") + break + else: + print("Geçersiz seçim. Lütfen tekrar deneyin!")