Сервис быстрых ответов от искусственного интеллекта
Вопрос пользователя:
Ответ нейросети:
import json
notes = {}
def save_notes():
with open("notes.json", "w") as file:
json.dump(notes, file)
def load_notes():
global notes
try:
with open("notes.json", "r") as file:
notes = json.load(file)
except FileNotFoundError:
notes = {}
def create_note():
title = input("Enter note title: ")
content = input("Enter note content: ")
notes[title] = content
save_notes()
print("Note created successfully!")
def read_note():
title = input("Enter note title: ")
if title in notes:
print(notes[title])
else:
print("Note not found")
def update_note():
title = input("Enter note title: ")
if title in notes:
content = input("Enter new content: ")
notes[title] = content
save_notes()
print("Note updated successfully!")
else:
print("Note not found")
def delete_note():
title = input("Enter note title: ")
if title in notes:
del notes[title]
save_notes()
print("Note deleted successfully!")
else:
print("Note not found")
def display_menu():
print("1. Create note")
print("2. Read note")
print("3. Update note")
print("4. Delete note")
print("5. Exit")
load_notes()
while True:
display_menu()
choice = input("Enter your choice: ")
if choice == "1":
create_note()
elif choice == "2":
read_note()
elif choice == "3":
update_note()
elif choice == "4":
delete_note()
elif choice == "5":
break
else:
print("Invalid choice. Please try again.")
print("Goodbye!")
Пример использования:
1. Create note
2. Read note
3. Update note
4. Delete note
5. Exit
Enter your choice: 1
Enter note title: My Note
Enter note content: This is a test note
Note created successfully!
1. Create note
2. Read note
3. Update note
4. Delete note
5. Exit
Enter your choice: 2
Enter note title: My Note
This is a test note
1. Create note
2. Read note
3. Update note
4. Delete note
5. Exit
Enter your choice: 3
Enter note title: My Note
Enter new content: This is an updated note
Note updated successfully!
1. Create note
2. Read note
3. Update note
4. Delete note
5. Exit
Enter your choice: 4
Enter note title: My Note
Note deleted successfully!
1. Create note
2. Read note
3. Update note
4. Delete note
5. Exit
Enter your choice: 5
Goodbye!
Напишите нам, если в вопросе есть ваши персональные данные (yasnoponyatno24@yandex.ru)
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.