Write a function named take_input() that asks the user for the names (strings) of the owner  and the company, and the names (strings), unit prices (floats), stock quantities (ints) of at least  3 products, and writes this information in a new text file using the following format.     owner_name,company_name  product1_name,product1_unitprice,product1_stock  product2_name,product2_unitprice,product2_stock  product3_name,product3_unitprice,product3_stock     The name of this text file can be taken as an input parameter of your function or you can choose  to use a pre-determined (fixed) name inside of this function. Your function must use exception  handling to handle all possible run-time errors so that this function does not crash. Please enter your name >> Bond  Hi Bond, please enter your company name >> Mart 007    Let's set up a sales menu for 'Mart 007'.    Enter item 1's name >> Spiked Umbrella  Enter item 1's unit price >> 7.25  Enter item 1's quantity >> 5    Enter item 2's name >> Voice Changer   Enter item 2's unit price >> 5.5  Enter item 2's quantity >> 10 Enter item 3's name >> Spy Camera  Enter item 3's unit price >> fifteen  Price must be a number. Please enter again >> -15  Price must be positive. Please enter again >> 15  Enter item 3's quantity >> eight  Stock must be a number. Please enter again >> -8  Stock must be positive. Please enter again >> 8    And the following will be written to the text file.    Bond,Mart 007  Spiked Umbrella,7.25,5  Voice Changer,5.5,10

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a function named take_input() that asks the user for the names (strings) of the owner 
and the company, and the names (strings), unit prices (floats), stock quantities (ints) of at least 
3 products, and writes this information in a new text file using the following format.  
 
owner_name,company_name 
product1_name,product1_unitprice,product1_stock 
product2_name,product2_unitprice,product2_stock 
product3_name,product3_unitprice,product3_stock  
 
The name of this text file can be taken as an input parameter of your function or you can choose 
to use a pre-determined (fixed) name inside of this function. Your function must use exception 
handling to handle all possible run-time errors so that this function does not crash.

Please enter your name >> Bond 
Hi Bond, please enter your company name >> Mart 007 
 
Let's set up a sales menu for 'Mart 007'. 
 
Enter item 1's name >> Spiked Umbrella 
Enter item 1's unit price >> 7.25 
Enter item 1's quantity >> 5 
 
Enter item 2's name >> Voice Changer  
Enter item 2's unit price >> 5.5 
Enter item 2's quantity >> 10

Enter item 3's name >> Spy Camera 
Enter item 3's unit price >> fifteen 
Price must be a number. Please enter again >> -15 
Price must be positive. Please enter again >> 15 
Enter item 3's quantity >> eight 
Stock must be a number. Please enter again >> -8 
Stock must be positive. Please enter again >> 8 
 
And the following will be written to the text file. 
 
Bond,Mart 007 
Spiked Umbrella,7.25,5 
Voice Changer,5.5,10  
Spy Camera,15,8

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY