Write a python program that reads from a text file whose name is provided by the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a python program that reads from a text file whose name is provided by the user, a list of a coffee shop products ordered by a customer (a sample input file is shown below). Each line contains item name, quantity and price (in biza) per product. Compute and display the total payment amount (in riyals) for each product as well as the total bill. Your program should consider the following erroneous cases: • The file does not open/exist The format of the data in the file is incorrect (e.g. quantity = "!" or price "8&0"), in which case RuntimeError exception should be raised and the processing stops. Note: Make sure you close any open file even if an error occurs. Enter filename: order1.txt Expresso:2 1200 Turkish coffee: 3 1250 Shish tawook:2 880 Coca cola: 1300 Water 1/2L: 100 Sample input file Product Expresso Turkish coffee Qty 2 3 Payment 2.40 3.75 File contents invalid. invalid literal for int() with base 10: '8&0' Sample output Total: 6.15 Write a python program that reads from a text file whose name is provided by the user, a list of a coffee shop products ordered by a customer (a sample input file is shown below). Each line contains item name, quantity and price (in biza) per product. Compute and display the total payment amount (in riyals) for each product as well as the total bill. Your program should consider the following erroneous cases: • The file does not open/exist The format of the data in the file is incorrect (e.g. quantity = "!" or price "8&0"), in which case RuntimeError exception should be raised and the processing stops. Note: Make sure you close any open file even if an error occurs. Enter filename: order1.txt Expresso:2 1200 Turkish coffee: 3 1250 Shish tawook:2 880 Coca cola: 1300 Water 1/2L: 100 Sample input file Product Expresso Turkish coffee Qty 2 3 Payment 2.40 3.75 File contents invalid. invalid literal for int() with base 10: '8&0' Sample output Total: 6.15
Expert Answer:
Answer rating: 100% (QA)
computes the total payment amount for each product and calculates the total bill python def processo... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Skip to main content Lab 11: A Web Server The goal of this lab is to write a simple, but functional, web server that is capable of sending files to a web browser on request. The web server must...
-
Pristine Thread Co. encountered a fire on March 12 where some of the inventory was destroyed. A physical count of inventory after the fire shows $56,000 still on hand. The company also had beginning...
-
The adjusted trial balance of Cook Antique Auctioneers at the end of its year, December 31, 2014, is shown below. Required 1. Prepare Cook Antique Auctioneers' 2014 income statement, statement of...
-
What is service?
-
You are in a meeting to decide on a new product development investment. The VP in charge of the meeting seems to be asking a lot of questions of the design engineers. And it also seems like the VP...
-
Refer to Problem 7.3. The head of the Mariposa County Accounting Department wants to establish a standard regarding the length of time that employees can expect to wait to receive reimbursement for...
-
What is the income summary account for? What is another name for the income summary account? What happens to the revenue and expense accounts after the closing process? Why do we close the draw...
-
WAR (We Are Rich) has been in business since 1988. WAR is an accrual-method sole proprietorship that deals in the manufacturing and wholesaling of various types of golf equipment. Hack & Hack CPAS...
-
We can test a claim about a population proportion using the P-value method of hypothesis testing or the critical value method of hypothesis testing, or we could base our conclusion on a confidence...
-
Shane Quadri contacted Don Hoffman, an employee of Al J. Hoffman & Co. (Hoffman Agency), to procure car insurance. Later, Quadris car was stolen. Quadri contacted Hoffman, who arranged with Budget...
-
Find the P-value in a test of the claim that the mean IQ score of acupuncturists is equal to 100, given that the test statistic is z = -2.00.
-
Chlorine (atomic number 17) is composed of two principal isotopes, chlorine-35, which has a mass of 34.9689 atomic mass units, and chlorine-37, which has a mass of 36.9659 atomic mass units. Assume...
-
In a recent Gallup poll of 511 adults, 64% said that they were in favor of the death penalty for a person convicted of murder. We want to use a 0.01 significance level to test the claim that the...
-
ABC Company has 50,000 employees and wants to increase employee productivity by setting up an internal software applications training program. The training program will teach employees how to use...
-
A bubble-point liquid feed is to be distilled as shown in Figure. Use the Edmister group method to estimate the mole-fraction compositions of the distillate and bottoms. Assume initial overhead and...
-
And, or, and not are __________ operators. a. Relational b. Logical c. Conditional d. Ternary
-
Write a program that creates a dictionary containing the U.S. states as keys, and their capitals as values. (Use the Internet to get a list of the states and their capitals.) The program should then...
-
Is the following assignment statement valid or invalid? If it is invalid, why? 72 = amount
-
What concept does density represent?
-
What are the seven SI base units and the physical quantities they represent?
-
What two pieces of information are necessary to express any physical quantity?
Study smarter with the SolutionInn App