Reading and Writing from Files
Автор: RedBullFroggy
Загружено: 2026-02-26
Просмотров: 8
Описание:
Program Goal
Create a simple program that reads notes from a file, allows the user to add a note, saves the updated list, and appends a log entry.
Files You Must Create
file_utils_example.py (functions live here)
notes_example.py (contains main())
notes_example.txt (stores the notes)
Program Requirements
file_utils_example.py must contain:
load_notes(filename) → reads notes from a file and returns a list
display_notes(notes) → prints all notes
add_note(notes) → asks for a new note and adds it to the list
save_notes(filename, notes) → writes all notes to the file (overwrite mode)
append_log(filename, note) → appends the added note to a log file
notes_example.py must contain:
import ALL functions individually using from file_utils_example import ...
contain main()
read from notes_example.txt when the program starts
allow the user to:
View notes
Add a note
Quit
when adding a note:
Rewrite notes.txt using write mode
Append the new note to log_example.txt using append mode
use the main guard:
if _name_ == "__main__": main()
Example Program Behavior
Notes Program
-------------
1) View notes
2) Add note
3) Quit
Choose: 1
1. Study Python
2. Finish homework
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: