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
79 changes: 79 additions & 0 deletions Customer Management System.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Question 1: Use a dictionary structure to store customer info with unique ID
customers = {}

# Question 2: Provide a menu for user actions
while True:

print("\n1. Add new customer")
print("2. Update customer")
print("3. Delete customer")
print("4. List all customers")
print("5. Check out (exit)")

choice = input("Choose an option: ")

# Question 3: Perform action based on user choice — Add customer
if choice == "1":
customer_id = input("Enter customer ID: ")
first_name = input("Enter first name: ")
last_name = input("Enter last name: ")
email = input("Enter email: ")
phone = input("Enter phone number: ")

customers[customer_id] = {
"first_name": first_name,
"last_name": last_name,
"email": email,
"phone": phone
}

print("Customer added!")

# Question 4: Update customer info using ID
elif choice == "2":
customer_id = input("Enter customer ID to update: ")
if customer_id in customers:
print("Current info:", customers[customer_id])
first_name = input("New first name: ")
last_name = input("New last name: ")
email = input("New email: ")
phone = input("New phone number: ")

customers[customer_id] = {
"first_name": first_name,
"last_name": last_name,
"email": email,
"phone": phone
}
print("Customer updated.")
else:
print("Customer not found.")

# Question 5: Delete customer by ID
elif choice == "3":
customer_id = input("Enter customer ID to Delete: ")
if customer_id in customers:
del customers[customer_id]
print("Customer deleted.")
else:
print("Customer not found!")

# Question 6: List all customers
elif choice =="4":
if customers:
for customer_id, info in customers.items():
print("ID:", customer_id)
print("Name:", info["first_name"], info["last_name"])
print("Email:", info["email"])
print("Phone:", info["phone"])
print("-" * 10)
else:
print("No customers yet.")

# Question 7: Repeat until user logs out
elif choice == "5":
print("Exiting Customer Management System. Goodbye!")
break

else:
print("Invalid option. Please choose 1–5.")
98 changes: 98 additions & 0 deletions Film Library Management System Project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import json


# Question 4: Restore the movie data when the program starts
try:
with open("mov.json", "r") as file:
movie_library = json.load(file)
except FileNotFoundError:
movie_library = []





# Question 2: Delete a field from a movie
def delete_movie(movie):
key_to_delete = input("Which field do you want to delete? (e.g., genre): ")
if key_to_delete in movie:
del movie[key_to_delete]
print(f"{key_to_delete} was deleted.")
else:
print("That field does not exist.")

# Question 3: View the movie collection (all, by genre, or year)
def view_movies():
choice = input("View all movies (all), by genre (genre), or by year (year)?: ")
if choice == "all":
for m in movie_library:
print(m)
elif choice == "genre":
g = input("Enter genre: ")
for m in movie_library:
if "genre" in m and m["genre"].lower() == g.lower():
print(m)
elif choice == "year":
y = input("Enter release year: ")
for m in movie_library:
if "Release year" in m and m["Release year"] == y:
print(m)
else:
print("Invalid option.")

# Question 4: Save the movie data in a file
def save_to_file():
with open("mov.json", "w") as file:
json.dump(movie_library, file, indent=4)

# Question 1: Create a movie dictionary with user input
movie = {
"Movie name": input("Enter Movie: "),
"Release year": input("Enter release year: "),
"genre": input("Enter genre: "),
"director": input("Enter director: ")
}
movie_library.append(movie)
save_to_file()
print("First movie saved!")


while True:
print("\n Movie Library Menu:")
print("1. Add another movie")
print("2. View movies")
print("3. Delete a field from last added movie")
print("4. Exit")

action = input("Choose an option: ")

if action == "1":
new_movie = {
"Movie name": input("Enter Movie: "),
"Release year": input("Enter release year: "),
"genre": input("Enter genre: "),
"director": input("Enter director: ")
}


movie_library.append(new_movie)
print("Movie added!")
save_to_file()

elif action == "2":
view_movies()

elif action == "3":
if movie_library:
delete_movie(movie_library[-1])
save_to_file()
else:
print("No movie to delete from.")

elif action == "4":
print("Goodbye!")
save_to_file()
break

else:
print("Invalid selection. Try again.")
41 changes: 41 additions & 0 deletions Israa_Question_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Question 1
students={
'Ahmet Yilmaz':[85,90,78],
'Mehmet Demir':[92,88,78],
'Ayse Kaya':[78,89,95],
'Zenep Celik':[65,70,80],
'Ali Kara':[50,60,55],
'Fatma Yildiz':[88,85,90],
'Murat ydin':[72,68,74],
'Elif Aksoy':[95,90,88],
'Hakan Ozturk':[45,50,55],
'Çanan Tas':[80,75,82]
}

# create new dictionary for averages and names:
averages={name:round(sum(grade)/len(grade),2) for name, grade in students.items()}
print('Averages : ', averages )
print('')

#find the student with the highest GPA:
heighest_GPA_student=max(averages)
heighest_GPA=averages[heighest_GPA_student]
print('Heighest GPA : ',heighest_GPA_student , ' ' , heighest_GPA)

print('')
#Separate each student's name from their surname and store them in a separate tuple and add them to a list
full_names=[( name.split()[0] ,name.split()[1] )for name in students.keys()]
print("Separate each student's name from their surname:")
print(full_names)

print('')
#Sort the names in alphabetical order and print the sorted list on the screen
names=[name[0] for name in full_names]
names.sort()
print('Sort the names in alphabetical order: ')
print(names)

print('')
#Keep students with a GPA below 70 in a cluster (set)
GPA_below_70={average for average in averages.values() if average<70}
print('students with a GPA below 70: ',GPA_below_70)
100 changes: 100 additions & 0 deletions Israa_Question_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#Question 2
import json

# Function to create a movie entry
def create_movie():
movie_name = input("Enter movie name: ")
director = input("Enter director: ")
release_year = input("Enter release year: ")
genre = input("Enter genre: ")
movie = {
"name": movie_name,
"director": director,
"release_year": release_year,
"genre": genre
}
return movie

# Function to edit a movie
def edit_movie(collection):
name_to_edit = input("Enter the name of the movie to edit: ")
for movie in collection:
if movie["name"] == name_to_edit:
print("Current details:", movie)
movie["name"] = input("Enter new movie name (or press Enter to keep current): ")
movie["director"] = input("Enter new director (or press Enter to keep current): ")
movie["release_year"] = input("Enter new release year (or press Enter to keep current): ")
movie["genre"] = input("Enter new genre (or press Enter to keep current): ")
print("Movie updated!")
print("Movie not found.")

# Function to delete a movie
def delete_movie(collection):
name_to_delete = input("Enter the name of the movie to delete: ")
for movie in collection:
if movie["name"] == name_to_delete:
collection.remove(movie)
print(f"Movie '{name_to_delete}' deleted!")

print("Movie not found.")

# Function to view movies
def view_collection(collection):
choice = input("View all movies or filter by genre/year? (all/genre/year): ").lower()
if choice == "all":
for movie in collection:
print(movie)
elif choice == "genre":
genre = input("Enter genre to filter: ")
filtered_movies = [movie for movie in collection if movie["genre"].lower() == genre.lower()]
for movie in filtered_movies:
print(movie)
elif choice == "year":
year = input("Enter year to filter: ")
filtered_movies = [movie for movie in collection if movie["release_year"] == year]
for movie in filtered_movies:
print(movie)
else:
print("Invalid choice.")

# Function to save data to a file
def save_data(collection):
with open("movies.json", "w") as file:
json.dump(collection, file)
print("Data saved successfully!")

# Function to load data from a file
def load_data():
try:
with open("movies.json", "r") as file:
return json.load(file)
except FileNotFoundError:
return []

# Main program loop
def main():
movie_collection = load_data()
while True:
print("\nFilm Library Management System")
print("1. Add a movie")
print("2. Edit a movie")
print("3. Delete a movie")
print("4. View collection")
print("5. Save and Exit")
choice = input("Enter your choice (1-5): ")
if choice == "1":
movie_collection.append(create_movie())
elif choice == "2":
edit_movie(movie_collection)
elif choice == "3":
delete_movie(movie_collection)
elif choice == "4":
view_collection(movie_collection)
elif choice == "5":
save_data(movie_collection)
print("Goodbye!")
break
else:
print("Invalid choice. Please try again.")

main()
Loading