Question
Use import statements as needed to make this application work. (2 points) For file handling, use Open and Close statements as appropriate. (2 points) You
Use import statements as needed to make this application work. (2 points)
For file handling, use Open and Close statements as appropriate. (2 points)
You will ask the user to enter the following data:
id: Any string is valid. Remove any leading or trailing spaces before assigning the value to the variable. In other words, all the work must be done in one line. (2 points)
price: Any decimal or integer number. Any conversion should be done before assigning the variable a value. In other words, all the work must be done in one line. (2 points)
color: This is a string input. You must convert it to UPPER CASE using Python’s built-in
functions before assigning it to the variable. Also, remove any leading or trailing spaces before assigning the value to the variable. In other words, all the work must be done in one line. (3 points)
If the user does not enter a valid value for id, the program should immediately exit and give an error message. (2 points)
If the user does not enter a valid value for color, the program should immediately exit and give an error message. (2 points)
Create a variable for internal use by your program. (1 points)
Create a variable called FILENAME. Keep it in uppercase as shown.
Assign this variable the value: item-data.txt
The user of your application should not be able to modify this variable.
Once the user has provided valid inputs, then save the values to a text file.
• If this file already exists, new data should be added to it at the end. If this files
does not exist, it should be automatically created. (3 points)
• The file name should reference the FILENAME variable created earlier (3 points) • You will ensure that each inventory item is in its own line. No two inventory
items should be on the same line (3 points)
Step by Step Solution
3.39 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
Answer Step 1 The necessary Python code is implemented in the following list of stages Complete func...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started