Question: Python The code I already have is pictured below as well as what I am supposed to add to it . If option 1 is
Python
The code I already have is pictured below as well as what I am supposed to add to it
If option is chosen, the program is to display the inventory in a tabular format as requested in MPro AND do the following:
write the information SAME FORMAT to a txt report titled "enventory.txt
write the book information, same information displayed, into a csv file. The file is to be named "envreport.csv
The csv file is to have the following column names Book Name, Author, Year Pub, Price each piece of information is to be written under the right column.
if option is chosen, do the following:
Display the list of books similar to how it was displayed in MPro
Ask the user to enter the book number they want to buy exactly how it worked in MPro
Ask the user if they wish to buy another book yesno again just how it worked in MPro.
Once the user no longer wants to buy books entered no go back to main menu
if option is chosen, do the following:
Display details of books purchased, exactly how it was requested and displayed in MPro
Write the purchased book details in a csv report titled "purchased.csv
The csv file is to have the following column names Book Name, Author, Year Pub, Price each piece of information is to be written under the right column.
After writing the book information in the csv file, write the book cost, tax and total price in the csv file Below the last populated row see example below
if option chosen, notify the user that the program will terminate and stop the program
if a value other than or is entered, display a message that notifies the user that an incorrect menu choice was entered and display the menu again.
Important points to remember...
The program is to only terminate If the user enters
Don't forget pseudocode
If new functions are created, don't forget to assign them docstrings
#function to display list of books
#lists
authors William Shakespeare","Charles Dickens","James Joyce","Earnest Hemingway","JK Rowling"
books Hamlet"A Tale of Two Cities","Ulysses","The Old Man and the Sea","Harry Potter and the Philosopher's Stone"
published
#list of book names
#list referencing book prices
prices
def bookdisplay:
function displays book information. Information retrieved from different lists
Returns
None.
printfNum:Book:Author:Year:Price
print
for i in rangelenauthors:
printfil:booksi:authorsi:publishedi:$pricesi
print
def showpurchasebooknums:
Parameters
booknums : list, references index number for books user wants to purchase
function displays information on the books selected
Returns
None.
# create
print
printfBook:Author:Year:Price
print
for i in booknums:
printfbooksi:authorsi:publishedi:$pricesi
def totalsbooknums:
Parameters
booknums : list, references index number for books user wants to purchase
Returns
cost : price total for books chosen
tax : tax on total price
total : cost tax
purprices
for i in booknums:
# get prices
price pricesi
purprices.append price
# add cost of both books
cost sumpurprices
tax cost
total cost tax
return cost, tax, total
File Edit Format Run Options Window Help
import mfunctions as fn
def main:
#display book list
fnbookdisplay
booknums
runagain y
While runagain y:
#ask user to enter book num
booknum intinput
Enter number of book you want to buy: # append to booknums after subtracting to get accurate index num
# find book info in all lists
booknum
booknums. append booknum
runagain input
Would you like to purchase another book? y for yes :
#pass to showpurchase function
fnshowpurchase booknums
cost tx total mathrmfntotals booknums
print
Total price cost of books tax:
printfBooks cost Before Tax $cost:f
printfTax $tax:f
printfTotal After Tax $total:f
# Call the main function.
if undersetoperatornamemaintext name main:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
