The expected results:
2012 vs. 1980s
March coverage fraction 0.969491525424
September coverage fraction 0.476319350474
2012 vs. 1990s
March coverage fraction 0.990990990991
September coverage fraction 0.527736131934
2012 vs. 2000s
March coverage fraction 1.01203113942
September coverage fraction 0.628571428571
Max winter coverage loss 0.969491525424
Max summer coverage loss 0.476319350474
What I get:
2012 vs. 2000s
March coverage fraction 0.969491525424
2012 vs. 1990s
March coverage fraction 0.990990990991
2012 vs. 2000s
March coverage fraction 1.01203113942
Max winter coverage loss 0.969491525424
Question:
Using only one function with four parameters, how can I get the September print statements right after the March statements?
My original idea was to call the function again with the parameters (s1980, s1990, s2000, s2012) but that gave me the wrong results!
My code:
Code:
#!/usr/bin/python3
m1980 = 14.75
m1990 = 14.43
m2000 = 14.13
m2012 = 14.30
s1980 = 7.39
s1990 = 6.67
s2000 = 5.60
s2012 = 3.52
def march_frac_years(w, x, y, z):
print '2012 vs. 2000s'
m2012_1980 = z/w
print ' March coverage fraction ' + str(m2012_1980)
print '2012 vs. 1990s'
m2012_1990 = z/x
print ' March coverage fraction ' + str(m2012_1990)
print '2012 vs. 2000s'
m2012_2000 = z/y
print ' March coverage fraction ' + str(m2012_2000)
max_winter = min(m2012_1980, m2012_1990, m2012_2000)
print 'Max winter coverage loss ' + str(max_winter)
march_frac_years(m1980, m1990, m2000, m2012)