3 Replies - 16943 Views - Last Post: 30 March 2009 - 03:02 PM Rate Topic: -----

#1 ramsay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-March 09

"Average" or "sum of" on python programming

Post icon  Posted 28 March 2009 - 10:48 AM

hello,

i am definitely on an entry level basis with programming. i just recently learned how to write a simple program in my class. for some reason i am having a difficult time with this problem:

A college wants you to write a program for them that will calculate the AVERAGE number of wins for their football team over the past FIVE years. the program user should be able to enter the number of wins each year. the program will calculate the average number of wins during that five year period and display that information to the screen.

i am using PYTHON GUI.

here is what i think i know:

season1=input("season1.")
season2=input("season2.")
season3=input("season3.")
season4=input("season4.")
season5=input("season5.")
average = (season1 + season2 + season3 + season4+ season5) /5
print 'the average is', average

by using these lines it is still not working. can anyone give me some advice? throw me a bone? im pulling my hair out here trying to figure it out myself.

thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: "Average" or "sum of" on python programming

#2 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 143
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: "Average" or "sum of" on python programming

Posted 28 March 2009 - 02:48 PM

If haven't mentioned what type of error you are having. If you just need to have the average with decimal point, then you can divide the sum with 5.0 instead of 5.
season1=input("season1.")
season2=input("season2.")
season3=input("season3.")
season4=input("season4.")
season5=input("season5.")
average = (season1 + season2 + season3 + season4+ season5) /5.0
print 'the average is', average


Or, if you are using python 3.0 or latest version, then probably your program is getting an error. Because print isn't a statement there, it is a function. For that case, you can do-
season1=input("season1.")
season2=input("season2.")
season3=input("season3.")
season4=input("season4.")
season5=input("season5.")
average = (season1 + season2 + season3 + season4+ season5) /5
print ('the average is', average)


Is it ok now? Let us know if you still having problem with what type of error you are getting.
Was This Post Helpful? 0
  • +
  • -

#3 davidaaron23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 17-February 09

Re: "Average" or "sum of" on python programming

Posted 29 March 2009 - 09:49 PM

hey r u itt tech if so im me i was in python last quarter and have alot of the work [removed]
Was This Post Helpful? 0
  • +
  • -

#4 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: "Average" or "sum of" on python programming

Posted 30 March 2009 - 03:02 PM

David,

I've edited out your email address. 1) We don't allow that sort of collaboratoin (i.e. giving people the solutions to homework) and 2) You'll end up getting spammed.

As an aside, I think there might be something wrong with your keyboard. Or you were visiting us from your cell phone. One or the other.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1