P08: Going Green Write the Python code for the following programming problem bel
ID: 3635072 • Letter: P
Question
P08: Going GreenWrite the Python code for the following programming problem below. You do not have to use modular design.
Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the energy difference from the two years and display the two years worth of data, along with the savings.
Hints: Create three arrays of size 12 each. The first array will store the first year of energy costs, the second array will store the second year after going green, and the third array will store the difference. Also, create a string array that stores the month names. These variables might be defined as follows:
notGreenCost = zeros(12,Float)
goneGreenCost = zeros(12,Float)
savings = zeros(12,Float)
months=str.array(itemsize=8,shape=12)
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
Explanation / Answer
Dear...
#Main Program
def Main():
notGreenCost = zeros(12,Float)
goneGreenCost = zeros(12,Float)
savings = zeros(12,Float)
months = ["January ","February","March ","April ","May ","June ","July ","August ","September ","October ","November ","December "]
for index in range(12):
print "Enter NOT GREEN energy costs for ", months[index]
notGreenCost=raw_input("Enter now-> ")
for index in range(12):
print "Enter GONE GREEN energy costs for ", months[index]
goneGreenCost=raw_input("Enter now-> ")
print " "
print "SAVINGS NOT GREEN GONE GREEN MONTH"
print " "
for index in range(12):
savings[index] = notGreenCost[index] - goneGreenCost[index]
print "$ ", savings[index]
print "$ ", notGreenCost[index]
print "$ ", goneGreenCost[index]
print months[index]
main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.