# "Average" or "sum of" on python programming

Page 1 of 1

## 3 Replies - 20025 Views - Last Post: 30 March 2009 - 03:02 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=95886&amp;s=f197a66d1c562d9ae40dec2a90a7477f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ramsay

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

# "Average" or "sum of" on python programming

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

• ???

Reputation: 144
• 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.

### #3 davidaaron23

Reputation: 0
• 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]

### #4 skyhawk133

Reputation: 1883
• Posts: 20,294
• 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.