Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON Your friend Julia has a problem. She goes grocery shopping on a weekly basis, and always seems to forget to buy items that

IN PYTHON

Your friend Julia has a problem. She goes grocery shopping on a weekly basis, and always seems to forget to buy items that she needs. You have suggested that she make a list before she goes, and have offered to write a program to help Julia produce her shopping list.

Your program should define and use the following functions to help perform the above tasks:

addItem (some_list)

The function addItem accepts one parameter, which is a list. This function

prompts the user for an item to be added to the list. If the item is not already

on the list, the item is added to the end of the list. Otherwise, a message is

given indicating that the item is already on the list.

removeItem(some_list)

The function addItem accepts one parameter, which is a list. This function

prompts the user for an item to be removed from the list. If the item on the list,

it is removed from the list. Otherwise, a message is given indicating that the

item was not on the list.

printOut(some_list)

The function printOut accepts one parameter, which is a list. This function prints out a header: GROCERY LIST

followed by a list of all of the items in the list, one at a time

THESE functions should be placed in a separate MODULE (another file). The main process will be in it's own file which import the function module in order to call these functions.

The main part of your program will start by creating an empty list. The user will then be allowed to choose any of the following options UNTIL he/she wishes to exit.

* ADD an item to the list

The user will provide the item to be added. If the item is not on the list, it will be added, otherwise a message will be given that the item is already

on the list. (You will call your addItem function to help here)

* FIND an item on the list

The user will provide an item and the program will report if the item is already on the list or not.

* PRINT all items

All items on the list are to be printed out, one per line (function printOut helps here)

* REMOVE an item from the list

The user will provide an item to be removed. If its there, it is removed, otherwise a

message is given. (You will call your removeItem function to help here)

Be sure your program is readable and well-commented. Test all options, remember some choices have two paths (eg. choosing ADD will either add an item or print a message).

Place your functions in their own file (module) and import this file into your main. Not only is this a more professional touch, but doing so is a good way to ensure that you are not using any global variables in your function!!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago