Question: Create a Python program that: Opens a file and reads the contents of the following file trips.txt The file contains several lines of data, with
Create a Python program that:
- Opens a file and reads the contents of the following file
- trips.txt
- The file contains several lines of data, with each data item separated by commas. The data is:
- A trip date
- The amount of fuel used on the trip
- The number of miles traveled on the trip
- The file contains several lines of data, with each data item separated by commas. The data is:
- trips.txt
- For each of the lines of data in the file, separate the data items and put them in appropriate variables
- The file contents are in the form of strings, so you must convert the numbers in the data into the proper type
- Calculate the fuel mileage achieved on each trip
- Display on a single line the:
- Trip data
- Amount of fuel used
- Numbers of miles traveled
- Fuel mileage calculated for the trip
- Create a new file to save the data read and the fuel mileage calculated for the trip
- Write the data on separate lines for each trip in the data, with each item separated by commas
- Remember that all of the data must be saved in the string form
The program should:
- Use variables with meaningful names
- Display easily understood prompts when collecting user input
- Prompt the user for the name of the file to read the data from, and the name of the file to store the revised data
- Have appropriate comments indicating what each part of the program is doing
- Have a comment area at the beginning of the program identifying the author of the program and the class it was created for
Save the program as a Python module, and submit the program through this assignment.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
