Python
an automobile sales program that requires you to first get the
number of automobiles which will be used to set the size of (2)
parallel lists or a 2 Dimensional list (your choice) that will
store the automobile Vehicle Identification Number (VIN) and Model.
You are required to display the contents of the list(s) and then
write the contents to a .csv or .txt file according to your
preference. Functions and Exception Handlers are required in this
program as described below:
In the main function…
The main function should use a try block as most likely you will
be processing the input into the lists in the within a for loop so
you can check for an IndexError in the Exception Handler, and check
for any other kind of error that may occur and print the error
message for it.
Here is what the program looks like when it runs. Look at the
input and see how the exception handlers are being used. Also, the
messages from the exception handlers are shown in italics when an
error occurs.
Enter the number of automobiles:
the number of automobiles
You must enter an integer > 0:
Enter the number of automobiles:
1.5
You must enter an integer > 0:
Enter the number of automobiles:
-1
You must enter a value > 0:
Enter the number of automobiles:
0
You must enter a value > 0:
Enter the number of automobiles:
2
Please enter the automobile VIN:
abc123
You must enter a VIN that has 17 characters:
Please enter the automobile VIN:
abc123bcd456987cba
You must enter a VIN that has 17 characters:
Please enter the automobile VIN:
abc123bcd456987cb
Please enter the Model:
Ford F150
Please enter the automobile VIN:
dec123
You must enter a VIN that has 17 characters:
Please enter the automobile VIN:
bca123bcd456987de
Please enter the Model:
Toyota Tacoma
Auto VINs
Model
abc123bcd456987cb Ford
F150
bca123bcd456987de Toyota
Tacoma
In [39]: Here is what the students_file.csv file contents look
like for the test data above:
['abc123bcd456987cb', 'Ford F150']
['bca123bcd456987de', 'Toyota Tacoma']
Submit your autos.py file in Canvas.
Python an automobile sales program that requires you to first get the number of automobiles which will be used to set th
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Python an automobile sales program that requires you to first get the number of automobiles which will be used to set th
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!