1994 Weekly Gas Graph (in python) Using matplotlib, write a Python program that
ID: 3738030 • Letter: 1
Question
1994 Weekly Gas Graph (in python)
Using matplotlib, write a Python program that reads the contentes of the file then plots the data as either a line graph or a bar chart. Be sure to display meaningful labels along the X and Y axes, as well as the tick marks.
1994 weekly gas txt- https://ufile.io/3pqkn
1994 Weekly Gas Graph In the student sample programs for this book, you will find a text file named 1994 Weekly Gas Averages.txt. The file contains the average gas price for each week in the year 1994. (There are 52 lines in the file.) Using matplotlib, write a Python program that reads the contonts ohlie then plots ih data as eihra n rapora bar chart. Be sure to display meaningful labels along the X and Yaxes, as well as the tick marks.Explanation / Answer
import matplotlib.pylot as plt
filename="1994_Weekly_Gas_Averages.txt"
with open(filename) as f:
content=f.readlines()
for line in content
print(line)
week=[1,2,3,4]
average_price[42.91,57.87,76.76,90.09,126.45,140.0]
plt.plot(week,average_price,color='green')
plt.xlabel('gas')
plt.ylabel('avg price')
plt.title('average gas price in 1994')
plt.show()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.