diff --git a/VIT_7_team_2_week2_HW.ipynb b/VIT_7_team_2_week2_HW.ipynb new file mode 100644 index 0000000..6f1d714 --- /dev/null +++ b/VIT_7_team_2_week2_HW.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "3459ccf3", + "metadata": {}, + "outputs": [], + "source": [ + "### Question1: Student Grades Processing\n", + "\n", + "You need to write a Python program to process a student's grades. The program needs to perform the following functions:\n", + "\n", + "Store information and notes for 10 students using a dictionary. Let each student have their name, surname and grades (Midterm, Final and Oral grades). \n", + "For example:\n", + "\n", + "![image](https://github.com/user-attachments/assets/0e3f85a4-bf24-4b22-b0ea-f9b3dbda4fc8)\n", + "\n", + "1-Calculate each student's GPA and add it to the dictionary.\n", + "\n", + "2-Find the student with the highest GPA and print it on the screen.\n", + "\n", + "3- Separate each student's name from their surname and store them in a separate tuple and add them to a list.\n", + "\n", + "4-Sort the names in alphabetical order and print the sorted list on the screen.\n", + "\n", + "5-Keep students with a GPA below 70 in a cluster (set)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92e8bac1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Ahmet Yılmaz': [85, 90, 78, 84.33], 'Mehmet Demir': [92, 88, 76, 85.33], 'Ayşe Kaya': [78, 89, 95, 87.33], 'Zeynep Çelik': [65, 70, 80, 71.67], 'Ali Kara': [50, 60, 55, 55.0], 'Fatma Yıldız': [88, 85, 90, 87.67], 'Murat Aydın': [72, 68, 74, 71.33], 'Elif Aksoy': [95, 90, 88, 91.0], 'Hakan Öztürk': [45, 50, 55, 50.0], 'Canan Taş': [80, 75, 82, 79.0]}\n", + "Student with the highest GPA is: Ahmet Yılmaz\n", + "His/Her GPA is: 90\n", + "[('Ahmet', 'Yılmaz'), ('Mehmet', 'Demir'), ('Ayşe', 'Kaya'), ('Zeynep', 'Çelik'), ('Ali', 'Kara'), ('Fatma', 'Yıldız'), ('Murat', 'Aydın'), ('Elif', 'Aksoy'), ('Hakan', 'Öztürk'), ('Canan', 'Taş')]\n", + "Ahmet Yılmaz\n", + "Ali Kara\n", + "Ayşe Kaya\n", + "Canan Taş\n", + "Elif Aksoy\n", + "Fatma Yıldız\n", + "Hakan Öztürk\n", + "Mehmet Demir\n", + "Murat Aydın\n", + "Zeynep Çelik\n", + "GPA'i 70'in altında olan öğrenciler: {'Ali Kara', 'Hakan Öztürk'}\n" + ] + } + ], + "source": [ + "students={\n", + " 'Ahmet Yılmaz': [85,90,78], #Midterm, Final, Oral\n", + " 'Mehmet Demir': [92,88,76],\n", + " 'Ayşe Kaya': [78,89,95],\n", + " 'Zeynep Çelik': [65,70,80],\n", + " 'Ali Kara': [50,60,55],\n", + " 'Fatma Yıldız': [88,85,90],\n", + " 'Murat Aydın': [72,68,74],\n", + " 'Elif Aksoy': [95,90,88],\n", + " 'Hakan Öztürk': [45,50,55],\n", + " 'Canan Taş': [80,75,82] \n", + "}\n", + "\n", + "# 1-Calculate each student's GPA and add it to the dictionary.\n", + "for student in students:\n", + " students[student].append(round((sum(students[student])/3),2))\n", + "print(students)\n", + "# 2-Find the student with the highest GPA and print it on the screen.\n", + "max_GPA=max(students.keys(), key=lambda x:students[x][-1])\n", + "print(f'Student with the highest GPA is: {max_GPA}\\nHis/Her GPA is: {students[max_GPA][-1]}')\n", + "\n", + "# 3- Separate each student's name from their surname and store them in a separate tuple and add them to a list.\n", + "names_surnames=[tuple(i.split()) for i in students]\n", + "print(names_surnames)\n", + "\n", + "# 4-Sort the names in alphabetical order and print the sorted list on the screen.\n", + "for i in sorted(students.keys()):\n", + " print(i)\n", + "\n", + "# 5-Keep students with a GPA below 70 in a cluster (set).\n", + "\n", + "GPA_below_70=dict(filter(lambda x: (x[1][-1])<70, students.items()))\n", + "GPA_below_70=set(GPA_below_70.keys())\n", + "print(f\"GPA'i 70'in altında olan öğrenciler: {GPA_below_70}\")\n", + " \n" + ] + }, + { + "cell_type": "markdown", + "id": "196dfc5d", + "metadata": {}, + "source": [ + "### Question 2: Film Library Management System Project\n", + "\n", + "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.\n", + "\n", + "Data Structures Used: Dictionaries (to store movies and related information), lists (to display movie collection)\n", + "\n", + "Basic Functions:\n", + "\n", + "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.\n", + "\n", + "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.)\n", + "\n", + "3-Allow the user to view their collection. List all movies or filter by criteria such as genre or year of release.\n", + "\n", + "4-Save the movie data in a file and restore this data when you start the program." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "6d2e9d9a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "There has been no entry so far. So start from 1 as movie_ID\n", + "\n", + "Movie added successfully! Current collection:\n", + "\n", + "=== Movie Collection ===\n", + "ID: 1 | Name: shawshank | Director: cames cameron | Year: 1997 | Genre: drama\n", + "========================\n", + "\n", + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "\n", + "Movie added successfully! Current collection:\n", + "\n", + "=== Movie Collection ===\n", + "ID: 1 | Name: shawshank | Director: cames cameron | Year: 1997 | Genre: drama\n", + "ID: 2 | Name: sdf | Director: rew | Year: 5487 | Genre: kokk\n", + "========================\n", + "\n", + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "\n", + "Viewing Options:\n", + "1 - View all movies\n", + "2 - Filter by release year\n", + "3 - Filter by genre\n", + "\n", + "=== Movie Collection ===\n", + "ID: 1 | Name: shawshank | Director: cames cameron | Year: 1997 | Genre: drama\n", + "ID: 2 | Name: sdf | Director: rew | Year: 5487 | Genre: kokk\n", + "========================\n", + "\n", + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "\n", + "Movie added successfully! Current collection:\n", + "\n", + "=== Movie Collection ===\n", + "ID: 1 | Name: shawshank | Director: cames cameron | Year: 1997 | Genre: drama\n", + "ID: 2 | Name: sdf | Director: rew | Year: 5487 | Genre: kokk\n", + "ID: | Name: | Director: | Year: | Genre: \n", + "========================\n", + "\n", + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "Invalid choice! Please try again.\n", + "\n", + "🎬 Film Library Management System\n", + "1. Add Movie\n", + "2. Edit Movie\n", + "3. Delete Movie\n", + "4. View Collection\n", + "5. Exit\n", + "Exiting the system. Goodbye!\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "# Veriyi dosyaya kaydeden fonksiyon\n", + "def save_data(movies):\n", + " with open('movies.json', 'w') as file:\n", + " json.dump(movies, file, indent=4)\n", + "\n", + "# Veriyi dosyadan okuyan fonksiyon\n", + "def load_data():\n", + " try:\n", + " with open('movies.json', 'r') as file:\n", + " return json.load(file)\n", + " except FileNotFoundError:\n", + " return []\n", + "\n", + "# Film ekleme fonksiyonu\n", + "def create_movie():\n", + " movies = load_data()\n", + "\n", + " if not movies:\n", + " print(\"There has been no entry so far. So start from 1 as movie_ID\")\n", + " \n", + " movie_ID = input('Enter Movie ID (Start from 1 and just go on...): ')\n", + " movie_name = input('Enter movie name: ')\n", + " director = input('Enter the director of the movie: ')\n", + " release_year = input('Enter the release year: ')\n", + " genre = input('Enter the genre of the movie: ')\n", + "\n", + " movie = {\n", + " 'movie_ID': movie_ID,\n", + " 'movie_name': movie_name,\n", + " 'director': director,\n", + " 'release_year': release_year,\n", + " 'genre': genre\n", + " }\n", + "\n", + " movies.append(movie)\n", + " save_data(movies)\n", + " print(\"\\nMovie added successfully! Current collection:\")\n", + " display_movies(movies)\n", + "\n", + "# Film düzenleme fonksiyonu\n", + "def edit_movie():\n", + " movies = load_data()\n", + " if not movies:\n", + " print(\"No movies to edit.\")\n", + " return\n", + "\n", + " display_movies(movies)\n", + " choice = input('Enter the movie ID that you want to edit: ')\n", + "\n", + " for movie in movies:\n", + " if movie['movie_ID'] == choice:\n", + " print(\"Leave field empty if you don't want to change it.\")\n", + " new_name = input('New movie name: ')\n", + " new_director = input('New director: ')\n", + " new_year = input('New release year: ')\n", + " new_genre = input('New genre: ')\n", + "\n", + " if new_name:\n", + " movie['movie_name'] = new_name\n", + " if new_director:\n", + " movie['director'] = new_director\n", + " if new_year:\n", + " movie['release_year'] = new_year\n", + " if new_genre:\n", + " movie['genre'] = new_genre\n", + "\n", + " save_data(movies)\n", + " print(\"Movie updated successfully!\")\n", + " display_movies(movies)\n", + " return\n", + "\n", + " print(\"Movie ID not found.\")\n", + "\n", + "# Film silme fonksiyonu\n", + "def delete_movie():\n", + " movies = load_data()\n", + " if not movies:\n", + " print(\"No movies to delete.\")\n", + " return\n", + "\n", + " display_movies(movies)\n", + " choice = input('Enter the movie ID that you want to delete: ')\n", + "\n", + " updated_movies = [movie for movie in movies if movie['movie_ID'] != choice]\n", + "\n", + " if len(updated_movies) == len(movies):\n", + " print(\"Movie ID not found.\")\n", + " else:\n", + " save_data(updated_movies)\n", + " print(\"Movie deleted successfully!\")\n", + " display_movies(updated_movies)\n", + "\n", + "# Film görüntüleme ve filtreleme\n", + "def view_collection():\n", + " movies = load_data()\n", + " if not movies:\n", + " print('There has been no entry so far.')\n", + " return\n", + "\n", + " print('\\nViewing Options:')\n", + " print('1 - View all movies')\n", + " print('2 - Filter by release year')\n", + " print('3 - Filter by genre')\n", + " choice = input('Enter your choice: ')\n", + "\n", + " if choice == '1':\n", + " display_movies(movies)\n", + " elif choice == '2':\n", + " year = input('Enter the release year: ')\n", + " filtered = [movie for movie in movies if movie['release_year'] == year]\n", + " display_movies(filtered)\n", + " elif choice == '3':\n", + " genre = input('Enter the genre: ')\n", + " filtered = [movie for movie in movies if movie['genre'].lower() == genre.lower()]\n", + " display_movies(filtered)\n", + " else:\n", + " print(\"Invalid choice.\")\n", + "\n", + "# Yardımcı fonksiyon: Film listesini güzel şekilde yazdırır\n", + "def display_movies(movies):\n", + " if not movies:\n", + " print(\"No movies found.\")\n", + " return\n", + " print(\"\\n=== Movie Collection ===\")\n", + " for movie in movies:\n", + " print(f\"ID: {movie['movie_ID']} | Name: {movie['movie_name']} | \"\n", + " f\"Director: {movie['director']} | Year: {movie['release_year']} | Genre: {movie['genre']}\")\n", + " print(\"========================\\n\")\n", + "\n", + "# Ana menü döngüsü\n", + "while True:\n", + " print(\"\\n🎬 Film Library Management System\")\n", + " print(\"1. Add Movie\")\n", + " print(\"2. Edit Movie\")\n", + " print(\"3. Delete Movie\")\n", + " print(\"4. View Collection\")\n", + " print(\"5. Exit\")\n", + " choice = input(\"Enter your choice: \")\n", + "\n", + " if choice == '1':\n", + " create_movie()\n", + " elif choice == '2':\n", + " edit_movie()\n", + " elif choice == '3':\n", + " delete_movie()\n", + " elif choice == '4':\n", + " view_collection()\n", + " elif choice == '5':\n", + " print(\"Exiting the system. Goodbye!\")\n", + " break\n", + " else:\n", + " print('Invalid choice! Please try again.')\n" + ] + }, + { + "cell_type": "markdown", + "id": "85781000", + "metadata": {}, + "source": [ + "### Question 3: Customer Management System\n", + "Project Description: This project involves you creating a customer management system that you can use to manage your customers and perform basic transactions. This system will have basic functions such as storing customer information, adding new customers, updating customer information, deleting customers and viewing the customer list. Here are the basic steps of the project:\n", + "\n", + "1-Use a dictionary structure to store customer information. Assign a unique customer identification (ID) for each customer and associate customer information with this ID. You can use a dictionary containing information such as name, surname, e-mail, phone number for each customer.\n", + "\n", + "2-Provide a menu where the user can choose the following actions:\n", + "\n", + "* Add new customers\n", + "* Updating customer information\n", + "* Delete customer\n", + "* List all customers\n", + "* Check out\n", + "\n", + "3-Perform the relevant action according to the user's choice. For example, when adding a new customer, get the required information from the user \n", + "and add a new customer to the dictionary.\n", + "\n", + "4-When updating customer information, view the current information using the customer ID and save the updated information.\n", + "\n", + "5-In the customer deletion process, get the customer ID from the user and delete this customer from the dictionary.\n", + "\n", + "6-In the process of listing all customers, view the list of existing customers.\n", + "\n", + "7-Repeat the process until the user logs out." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b23287a6", + "metadata": {}, + "outputs": [], + "source": [ + "customers=[]\n", + "def add_customer():\n", + " if len(customers)==0:\n", + " customer_ID='1'\n", + " else: \n", + " customer_ID=str(len(customers)+1)\n", + " print(f'For customer {customer_ID}:')\n", + " customer_name=input('Please enter the name of the customer: ')\n", + " customer_surname=input('Please enter the surname of the customer: ')\n", + " customer_email=input('Please enter the e-mail of the customer: ')\n", + " customer_phonenumber=input('Please enter the phone number of the customer: ')\n", + " customer={\n", + " 'customer_ID':customer_ID, 'customer_name':customer_name, 'customer_surname':customer_surname,\n", + " 'customer_email':customer_email, 'customer_phonenumber':customer_phonenumber\n", + " }\n", + " customers.append(customer)\n", + " for customer in customers:\n", + " print(customer)\n", + " \n", + "def update_customer():\n", + " for customer in customers:\n", + " print(customer)\n", + " print()\n", + " choice=input('Enter the ID number of the customer whose information you want to update: ')\n", + " found=False\n", + " for customer in customers:\n", + " if customer['customer_ID']==choice:\n", + " customer['customer_name']=input('Please renew the name of the customer: ')\n", + " customer['customer_surname']=input('Please renew the surname of the customer: ')\n", + " customer['customer_email']=input('Please renewr the e-mail of the customer: ')\n", + " customer['customer_phonenumber']=input('Please renew the phone number of the customer: ')\n", + " found=True\n", + " break\n", + " if not found:\n", + " print('You made a invalid entry...!')\n", + " \n", + "def delete_customer():\n", + " for customer in customers:\n", + " print(customer)\n", + " print()\n", + " choice=input('Enter the ID number of the customer whose information you want to delete: ')\n", + " for customer in customers:\n", + " if customer['customer_ID']==choice:\n", + " customers.remove(customer)\n", + " print(f'Customer {choice} has been deleted.')\n", + " break\n", + " else:\n", + " print('Invalid customer ID')\n", + " \n", + "def list_customer():\n", + " for customer in customers:\n", + " print(customer)\n", + " \n", + "\n", + "while True:\n", + " print('Customer management System')\n", + " print('---------------------------------')\n", + " print(\"Enter '1' to add a new customer \")\n", + " print(\"Enter '2' to update a customer information: \")\n", + " print(\"Enter '3' to delete a customer information: \")\n", + " print(\"Enter '4' to list all the customer information: \")\n", + " print(\"Enter '5' to exit: \")\n", + " choice=input('Enter your choice: ')\n", + " if choice=='1':\n", + " add_customer()\n", + " elif choice=='2':\n", + " update_customer()\n", + " elif choice=='3':\n", + " delete_customer()\n", + " elif choice=='4':\n", + " list_customer()\n", + " elif choice=='5':\n", + " break\n", + " else:\n", + " print('Wrong entry! Please try again: ')\n", + " \n", + "\n", + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/movies.json b/movies.json new file mode 100644 index 0000000..8db117f --- /dev/null +++ b/movies.json @@ -0,0 +1,23 @@ +[ + { + "movie_ID": "1", + "movie_name": "shawshank", + "director": "cames cameron", + "release_year": "1997", + "genre": "drama" + }, + { + "movie_ID": "2", + "movie_name": "sdf", + "director": "rew", + "release_year": "5487", + "genre": "kokk" + }, + { + "movie_ID": "", + "movie_name": "", + "director": "", + "release_year": "", + "genre": "" + } +] \ No newline at end of file diff --git a/movies.txt b/movies.txt new file mode 100644 index 0000000..5d34c33 --- /dev/null +++ b/movies.txt @@ -0,0 +1 @@ +shawshank,ben,2003,horror