Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Igor Korot Newsgroups: comp.lang.python Subject: Re: Average calculation Program *need help* Date: Thu, 12 May 2016 12:06:24 -0400 Lines: 37 Message-ID: References: <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de UAI8nvhka9djH4HB/viKgAp74VNzqJUJYl2+J+uPKkBA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:help': 0.07; 'cc:addr:python-list': 0.09; 'python.': 0.11; 'def': 0.13; 'translate': 0.15; 'thu,': 0.15; '"your': 0.16; '#this': 0.16; '2016': 0.16; 'range(0,': 0.16; 'range,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; 'all,': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'algorithm': 0.20; 'are.': 0.22; 'am,': 0.23; 'help.': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'message- id:@mail.gmail.com': 0.27; 'function': 0.28; 'code:': 0.29; "i'm": 0.30; 'print': 0.30; '(including': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'supposed': 0.31; 'run': 0.33; 'problem': 0.33; 'url:python': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'two': 0.37; '12,': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'someone': 0.38; 'thank': 0.38; 'hi,': 0.38; 'test': 0.39; 'url:mail': 0.40; 'still': 0.40; 'total': 0.62; 'you.': 0.64; 'hours': 0.65; 'between': 0.65; 'score': 0.76; 'number):': 0.84; 'score:': 0.84; 'subject: *': 0.84; 'scores': 0.91; 'average': 0.93; 'subject:*': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=u9DwBj//YBsKU/vK//yPCF/b4gW/1WwDUqsER0ej9NI=; b=YAYn/yVinoxMzTPeooP5d7dVGUl4usWvW0KazTcua0O7GPUJCu4QI3tsXcVyXsUjIn zREQ3WvRTMxwLAbZGnLukyy0lHh8M9EXVRPfohqrgDWMKrQjLOD0rMRrnoE2CyTwIXuk zstkq03idNlW0QmGjlwZ7vma4WGeg0z8hL5xeuUsq7WyzvkvY9wqsgAOlKxicR+QS0OY ci+g/08LYHeMDO3XmOCWcwn3ZKYXrnYNjYwnFmwT6wrCLBdmhzIeTC5TVACuVJEPAT3W lTek9mXF4RZazBYUtdWu82lvg2XZWBA43J1QCVxapf2z75is1tGC/8aNFqjF/E9Q2I1H inyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=u9DwBj//YBsKU/vK//yPCF/b4gW/1WwDUqsER0ej9NI=; b=gM/NZ1nw/hAQtA2p2Bck4Ctzeb0oKtIBqqSKAFQM+TluaBVPXYHHDrN0UDszv14vOh bLCvKt7xaTboIF5YX4QZxAmECCqwv2Ezd6CVVgTo7TjvDqPpoEZaCODUZyNtSqhWjer3 PAVrwSVo7oB1MAzSQWMT3kO88tnU7tNIawySuABTipS1+nN7uxKlQIX1BQPDa0dWgAbu CUDQZML9/ap5LMdY3dYHAajRE3mfYRfL3cu3gCuUCQjpmOaweSgoKkAchpLgm5XE9VyH ll7rjWxJGV3OGDXbLVSSHaFr8xvnbVSjUqfsYcVyJhwZEkbSx9bpLzTBTV+4elhkmIye MklQ== X-Gm-Message-State: AOPr4FVu8FFHTW04vDlQ643fjEYPELpb/O7TPc3QkyxsJu9XOYJ2pyR6PlDhrDk6nhjcKtPbBUvmWMrxKSoUow== X-Received: by 10.176.4.20 with SMTP id 20mr5149308uav.125.1463069184702; Thu, 12 May 2016 09:06:24 -0700 (PDT) In-Reply-To: <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> Xref: csiph.com comp.lang.python:108562 Hi, On Thu, May 12, 2016 at 11:47 AM, 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 =3D input('Enter their score: ') > totalScores =3D totalScores + score > > while not (score >=3D 0 and score <=3D 100): > > print "Your score must be between 0 and 100." > score =3D 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 displ= ayed. The main problem with this is that when someone types in a number out= side of the range, it'll ask them to enter two scores again, but ends up ad= ding all of the scores together (including the invalid ones) and dividing b= y 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