Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108562

Re: Average calculation Program *need help*

From Igor Korot <ikorot01@gmail.com>
Newsgroups comp.lang.python
Subject Re: Average calculation Program *need help*
Date 2016-05-12 12:06 -0400
Message-ID <mailman.613.1463069194.32212.python-list@python.org> (permalink)
References <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> <CA+FnnTyM45xgcj_Hm7g-72mqnUE7mCHyF8pfdbw5yj5Cyg9o+Q@mail.gmail.com>

Show all headers | View raw


Hi,

On Thu, May 12, 2016 at 11:47 AM,  <kobsx4@gmail.com> wrote:
> Hello all, I have been struggling with this code for 3 hours now and I'm still stumped. My problem is that when I run the following code:
> ------------------------------------------------------------------------------
> #this function will get the total scores
> def getScores(totalScores, number):
>     for counter in range(0, number):
>         score = input('Enter their score: ')
>         totalScores = totalScores + score
>
>     while not (score >= 0 and score <= 100):
>
>         print "Your score must be between 0 and 100."
>         score = input('Enter their score: ')
>
>
>
>     return totalScores
> ------------------------------------------------------------------------------
> the program is supposed to find the average of two test scores and if one of the scores is out of the score range (0-100), an error message is displayed. The main problem with this is that when someone types in a number outside of the range, it'll ask them to enter two scores again, but ends up adding all of the scores together (including the invalid ones) and dividing by how many there are. Please help.

Can you solve this problem with just pen and paper?
Do that and then translate the algorithm to python.

Thank you.

> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Average calculation Program *need help* kobsx4@gmail.com - 2016-05-12 08:47 -0700
  Re: Average calculation Program *need help* Rustom Mody <rustompmody@gmail.com> - 2016-05-12 09:01 -0700
  Re: Average calculation Program *need help* Igor Korot <ikorot01@gmail.com> - 2016-05-12 12:06 -0400
    Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-12 19:45 -0400
  Re: Average calculation Program *need help* "Martin A. Brown" <martin@linux-ip.net> - 2016-05-12 09:13 -0700
  Re: Average calculation Program *need help* MRAB <python@mrabarnett.plus.com> - 2016-05-12 17:14 +0100
  Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 21:22 -0700
    Re: Average calculation Program *need help* Ben Finney <ben+python@benfinney.id.au> - 2016-05-13 14:55 +1000
    Re: Average calculation Program *need help* Michael Torrie <torriem@gmail.com> - 2016-05-12 22:57 -0600
      Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 22:03 -0700
        Re: Average calculation Program *need help* Michael Torrie <torriem@gmail.com> - 2016-05-12 23:29 -0600
    Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-13 01:12 -0400
  Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 22:46 -0700
    Re: Average calculation Program *need help* Nick Sarbicki <nick.a.sarbicki@gmail.com> - 2016-05-13 07:10 +0000
      Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-13 08:38 -0700
        Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-13 12:17 -0400

csiph-web