1 Replies - 665 Views - Last Post: 05 October 2016 - 02:00 AM Rate Topic: -----

#1 ashleytraan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-October 16

Rainfall stats python help

Posted 04 October 2016 - 08:50 PM

Hello, I have figured out a code that will work in Python. However I did not include user validation. I am not sure how to modify my code to do so. Can someone please take a look at my code and help me? I have only learned if/elif/else statements and while loop (no for loop) so far. So i cannot use anything beyond that scope. Thanks :helpsmilie:
#user input
year=[]
jan=float(input('Please enter Jan rainfall: '))
feb=float(input('Please enter Feb rainfall: '))
mar=float(input('Please enter Mar rainfall: '))
apr=float(input('Please enter Apr rainfall: '))
may=float(input('Please enter May rainfall: '))
jun=float(input('Please enter Jun rainfall: '))
jul=float(input('Please enter Jul rainfall: '))
aug=float(input('Please enter Aug rainfall: '))
sep=float(input('Please enter Sep rainfall: '))
oct=float(input('Please enter Oct rainfall: '))
nov=float(input('Please enter Nov rainfall: '))
dec=float(input('Please enter Dec rainfall: '))

year.extend((jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec))

#
def lowest():
print('The minimum rainfall is', min(year))
lowest()

def highest():
print('The most rainfall is', max(year))
highest()

def total():
print('The total rainfall is', sum(year))
total()

def average():
print('The average rainfall is', float(sum(year))/len(year))
average()

Is This A Good Question/Topic? 0
  • +

Replies To: Rainfall stats python help

#2 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 562
  • View blog
  • Posts: 1,798
  • Joined: 27-December 13

Re: Rainfall stats python help

Posted 05 October 2016 - 02:00 AM

I guess you will find inspiration from this tutorial: http://www.dreaminco...and-game-loops/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1