Question: Hi, I would need to do the following with Python. How is it done? Make a program that gives the user an option (1) read

Hi,

I would need to do the following with Python. How is it done?

Make a program that gives the user an option

(1) read the contents of the notebook,

(2) Add an entry or

(3) Clears the entire notebook

In addition, add selection (4), which ends the program. If the user selects 1, the content of the file is printed on the screen, if 2, the program asks "Write a new entry: " and saves the entry in the memo, adding a newline character " " to the end of the entry so that the entries remain on different lines. If the user selects 3, the file is cleared and the text "Notebook cleared" is printed on the screen. and with choice 4, the program announces "Quit." and turns off. With other choices, the program says "Unknown choice.". When running, the program prints the following:

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 2

Write a new entry: -Buy milk

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 1

- Buy some milk

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 4

Let's stop.

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 2

Write a new entry: -Buy milk

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 1

- Buy some milk

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 4

Let's stop.

Note that the fastest way to clear a file is to open it in "w" mode and close it at the same time.

Example output:

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 1

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 2

Write a new entry: -Buy juice

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 1

-Buy some juice

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 3

Memo cleared.

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 1

(1) Read the notebook

(2) Add an entry

(3) Clear the notebook

(4) Stop

What do you want to do?: 4

Let's stop.

-------------------------------------------------------------------------------------------

Thanks in advance!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!