Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import os import pickle import subprocess class AlwaysNote: def _ _ init _ _ ( self ) : self.notes = [ ] self.filename = notes.pkl
import os
import pickle
import subprocess
class AlwaysNote:
def initself:
self.notes
self.filename "notes.pkl
self.loadnotes
def clearscreenself:
subprocess.callcls if osname nt else 'clear', shellTrue
def displaymenuself:
print: ALWAYSNOTE :
print gold edition
print
self.displaynotestitles
print
printview view note"
printadd add note"
printrm remove note"
printexit exit program"
print
def displaynotestitlesself:
for note in self.notes:
printfnotetitle
def viewnoteself title:
self.clearscreen
for note in self.notes:
if notetitle title:
printf
notetitle
print
inputPress enter to continue..."
printf
Description: notedescription
inputPress Enter to continue..."
break
else:
print
printf
ERROR: Unknown note
print
inputPress Enter to continue..."
def addnoteself title, description:
self.notes.appendtitle: title, 'description': description
print
print
INFO: Note added!
inputPress Enter to continue..."
def removenoteself title:
for note in self.notes:
if notetitle title:
self.notes.removenote
print
INFO: Note deleted successfully
print
inputPress Enter to continue..."
break
else:
print
print
ERROR: Unknown note
print
inputPress Enter to continue..."
def savenotesself:
with openselffilename, wb as file:
pickle.dumpselfnotes, file
def loadnotesself:
if ospath.existsselffilename:
with openselffilename, rb as file:
self.notes pickle.loadfile
def runself:
while True:
self.clearscreen # Move clearscreen outside the loop
self.displaymenu
choice inputmenu lower
print
if choice 'view':
title inputtitle
self.viewnotetitle
elif choice 'add':
title inputtitle
description inputdescr
self.addnotetitle description
elif choice rm:
title inputtitle
self.removenotetitle
elif choice 'exit':
self.savenotes
printExiting program. Goodbye!"
break
else:
printInvalid choice. Please try again."
if namemain:
alwaysnoteapp AlwaysNote
alwaysnoteapp.run the menu must print only once after each operation. Do not change anything else.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started