Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the file gas _ prices.txt ( linked below ) you will find weekly U . S . gas prices for 1 9 9 4

In the file gas_prices.txt (linked below) you will find weekly U.S. gas prices for 1994 through 2012. The format is :, as follows:
01-03-1994:0.992
01-10-1994:0.995
01-17-1994:1.001
01-24-1994:0.999
01-31-1994:1.005
02-07-1994:1.007
02-14-1994:1.016
02-21-1994:1.009
02-28-1994:1.004
03-07-1994:1.007
...
Write a program that reads this file and outputs a report containing the low price, average price, and high prices for each year, as well as the average prices for each month of each year, sorted by year and month, as follows:
1994:
Low: $0.99, Avg: $1.08, High: $1.17
January $1.00
February $1.01
March $1.01
April $1.03
May $1.05
June $1.08
July $1.11
August $1.15
September $1.14
October $1.11
November $1.12
December $1.13
1995:
Low: $1.11, Avg: $1.16, High: $1.25
January $1.13
February $1.12
March $1.12
April $1.16
May $1.23
June $1.24
July $1.20
August $1.17
September $1.16
October $1.13
November $1.11
December $1.12
...
Redirect your report to a file named gas_report.txt. Submit that file along with your code in a file named gasprices.py
To redirect output from a program to a file, use > in the command line when you run your program, as shown in this example:
python3 gasprices.py > gas_report.tx

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions