diff --git a/data.json b/data.json new file mode 100644 index 0000000..3446fc9 --- /dev/null +++ b/data.json @@ -0,0 +1,44 @@ +[ + { + "title": "Movie 1", + "director": "Steven Spielberg", + "year": 1998, + "genre": "Romance" + }, + { + "title": "Movie 2", + "director": "Guillermo del Toro", + "year": 1995, + "genre": "Drama" + }, + { + "title": "Movie 3", + "director": "Kathryn Bigelow", + "year": 2020, + "genre": "Action" + }, + { + "title": "a", + "director": "a", + "year": 2025, + "genre": "a" + }, + { + "title": "a", + "director": "a", + "year": 2025, + "genre": "a" + }, + { + "title": "Block", + "director": "Buster", + "year": 2020, + "genre": "me" + }, + { + "title": "me", + "director": "me", + "year": 2005, + "genre": "me" + } +] \ No newline at end of file diff --git a/zahid_team_leader_movie.py b/zahid_team_leader_movie.py new file mode 100644 index 0000000..6e6c3fc --- /dev/null +++ b/zahid_team_leader_movie.py @@ -0,0 +1,26 @@ +import json,sys +#save movie data in dictionary +try: + def write_json(new_data, filename='data.json'): + with open(filename,'r+') as file: + file_data = json.load(file) + file_data.append(new_data) + file.seek(0) + return json.dump(file_data, file, indent = 4) + + mname = input("Enter movie name ") + mdirector = input("Enter movie director name ") + myear = int(input("Enter year ")) + genre = input("Enter Genre ") + dic={} + dic.update({"title":mname,"director":mdirector,"year":myear,"genre":genre}) + write_json(dic) + print("Data saved in file and showing data from file") + f = open('data.json') + data = json.load(f) + for i in data: + print(f"{i}\n") + f.close() + sys.exit() +except: + print("Please eneter numbers") diff --git a/zahid_team_leader_question1-3.py b/zahid_team_leader_question1-3.py new file mode 100644 index 0000000..e9fb5e7 --- /dev/null +++ b/zahid_team_leader_question1-3.py @@ -0,0 +1,23 @@ +# Question no 3 +# Separate each student's name from their surname and store them in a separate tuple and add them to a list. + +students = { +'Ahmet Yilmaz': [85,90, 78], +'Mehmet emir': [92,88, 76], +'Ayse Kaya': [78,89, 95], +'Zeynep Celik': [65,70, 80], +'Ali Kara': [50,60, 55], +'Fatma Yildiz': [88,85, 90], +'Murat Aydin': [72,68,74], +'Elif Aksoy': [95,90,88], +'Hakan Oztiirk':[45,50,55], +'Canan Tas': [80,75,82] +} + +name_surname_list = [] + +for full_name in students.keys(): + first_name, last_name = full_name.split() + name_surname_list.append((first_name, last_name)) + +print(name_surname_list) \ No newline at end of file diff --git a/zahid_team_leader_question1-4.py b/zahid_team_leader_question1-4.py new file mode 100644 index 0000000..f37f5a5 --- /dev/null +++ b/zahid_team_leader_question1-4.py @@ -0,0 +1,17 @@ +# Question no 1 part 4 +# Sort the names in alphabetical order and print the sorted list on the screen. + +students = { +'Ahmet Yilmaz': [85,90, 78], +'Mehmet emir': [92,88, 76], +'Ayse Kaya': [78,89, 95], +'Zeynep Celik': [65,70, 80], +'Ali Kara': [50,60, 55], +'Fatma Yildiz': [88,85, 90], +'Murat Aydin': [72,68,74], +'Elif Aksoy': [95,90,88], +'Hakan Oztiirk':[45,50,55], +'Canan Tas': [80,75,82] +} + +print(dict(sorted(students.items()))) \ No newline at end of file diff --git a/zahid_team_leader_question1-5.py b/zahid_team_leader_question1-5.py new file mode 100644 index 0000000..6381b4d --- /dev/null +++ b/zahid_team_leader_question1-5.py @@ -0,0 +1,24 @@ +# Question no 1 part 4 +# Sort the names in alphabetical order and print the sorted list on the screen. + +students = { +'Ahmet Yilmaz': [85,90, 78], +'Mehmet emir': [92,88, 76], +'Ayse Kaya': [78,89, 95], +'Zeynep Celik': [65,70, 80], +'Ali Kara': [50,60, 55], +'Fatma Yildiz': [88,85, 90], +'Murat Aydin': [72,68,74], +'Elif Aksoy': [95,90,88], +'Hakan Oztiirk':[45,50,55], +'Canan Tas': [80,75,82] +} + +gpa_students = set() + +for name, grades in students.items(): + gpa = sum(grades) / len(grades) + if gpa < 70: + gpa_students.add(name) + +print(gpa_students,'\n',type(gpa_students)) \ No newline at end of file diff --git a/zahid_team_leader_question1-to-2.py b/zahid_team_leader_question1-to-2.py new file mode 100644 index 0000000..2af877c --- /dev/null +++ b/zahid_team_leader_question1-to-2.py @@ -0,0 +1,18 @@ +# Question no 1 +students = { +'Ahmet Yilmaz': [85,90, 78], +'Mehmet emir': [92,88, 76], +'Ayse Kaya': [78,89, 95], +'Zeynep Celik': [65,70, 80], +'Ali Kara': [50,60, 55], +'Fatma Yildiz': [88,85, 90], +'Murat Aydin': [72,68,74], +'Elif Aksoy': [95,90,88], +'Hakan Oztiirk':[45,50,55], +'Canan Tas': [80,75,82] +} +new_dic = {} +for key,values in students.items(): + gpa_each_student = round(sum(values) / len(values), 2) + new_dic.update({key:gpa_each_student}) +print(max(sorted(new_dic.items()), key=lambda x: x[1])); \ No newline at end of file diff --git a/zahid_team_leader_question2.py b/zahid_team_leader_question2.py new file mode 100644 index 0000000..f85fb37 --- /dev/null +++ b/zahid_team_leader_question2.py @@ -0,0 +1,86 @@ +# Question no 1 part 2 +import sys +customers = { + 1001: {"name": "Ahmet", "surname": "Yilmaz", "email": "ahmet.yilmaz@example.com", "phone": "+905301112233"}, + 1002: {"name": "Ayse", "surname": "Kaya", "email": "ayse.kaya@example.com", "phone": "+905301234567"}, + 1003: {"name": "Mehmet", "surname": "Emir", "email": "mehmet.emir@example.com", "phone": "+905306789012"}, + 1004: {"name": "Elif", "surname": "Aksoy", "email": "elif.aksoy@example.com", "phone": "+905308765432"}, + 1005: {"name": "Zeynep", "surname": "Celik", "email": "zeynep.celik@example.com", "phone": "+905309876543"}, + 1006: {"name": "Ali", "surname": "Kara", "email": "ali.kara@example.com", "phone": "+905304445566"}, + 1007: {"name": "Fatma", "surname": "Yildiz", "email": "fatma.yildiz@example.com", "phone": "+905307778899"}, + 1008: {"name": "Murat", "surname": "Aydin", "email": "murat.aydin@example.com", "phone": "+905302223344"}, + 1009: {"name": "Hakan", "surname": "Oztiirk", "email": "hakan.oztiirk@example.com", "phone": "+905305556677"}, + 1010: {"name": "Canan", "surname": "Tas", "email": "canan.tas@example.com", "phone": "+905309999000"} +} + +menu = "Add new customers (Press 1)\nUpdating customer information ( Enter 2 ) \nDelete customer ( Enter 3 )\nList all customers ( Enter 4 )" +print(menu) +menu_choice = 0 +try: + menu_choice = int(input("Select a above numner to perform a action")) +except ValueError: + print("Please enter only numbers") + sys.exit() + +def add_new_customer(): + try: + fname = input("Enter your first name") + sname = input("Enter your sur name") + email = input("Enter your Email") + phone = input("Enter your Phone") + unique_id = max(sorted(customers.items()), key=lambda x: x[0])[0]+1 + customers.update({unique_id:{'name':fname,'surname':sname,'email':email,'phone':phone}}) + return customers + except: + print("There is some error") + +def list_all_customer(): + try: + for customer in customers: + #print(customers[customer]) + print(f"Name: {customers[customer]['name']} {customers[customer]["surname"]} Email: {customers[customer]["email"]} Phone: {customers[customer]["phone"]}") + except: + return "Some Error in User List Printing" + +def update_customer(): + try: + id = int(input("Enter the Customer ID which you want to edit")) + try: + print(f"You are going to Change customer {customers[id]['surname']}") + fname = input(f"Please Enter first name") + sname = input(f"Please Enter sur name") + email = input(f"Please Enter email") + phone = input(f"Please Enter phone") + if fname != "": + customers[id]['name'] = fname + if sname != "": + customers[id]['surname'] = sname + if email != "": + customers[id]['email'] = email + if email != "": + customers[id]['phone'] = phone + list_all_customer() + except: + return "Customer not find" + except ValueError: + return "Please enter numbers only" + +def delete_customer(): + id = int(input("Enter the Customer ID which you want to edit")) + try: + del customers[id] + list_all_customer() + except ValueError: + return "Please enter numbers only" + +def view_customer(): + return list_all_customer() + +if menu_choice == 1: + print(add_new_customer()) +elif menu_choice == 2: + print(update_customer()) +elif menu_choice == 3: + print(delete_customer()) +elif menu_choice == 4: + print(view_customer())