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


Groups > comp.lang.python > #59045

Re: Help - Exercise Decision

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <gary.herron@islandtraining.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'that?': 0.05; 'assignment': 0.07; 'assuming': 0.09; 'combines': 0.09; 'correct,': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'subject:Help': 0.11; '"or"': 0.16; "'''": 0.16; "(i'm": 0.16; 'equal.': 0.16; 'holy': 0.16; 'operator.': 0.16; 'segunda': 0.16; 'sorting': 0.16; 'comment:': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'trying': 0.19; 'else,': 0.19; 'practices,': 0.19; 'entered': 0.20; 'examples': 0.20; '>>>': 0.22; '(in': 0.22; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'question': 0.24; 'sort': 0.25; 'received:(smtp server)': 0.26; 'post': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'said,': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'lines': 0.31; 'you?': 0.31; 'equality': 0.31; 'gary': 0.31; 'please.': 0.31; 'produces': 0.31; 'quite': 0.32; 'guess': 0.33; 'link.': 0.33; "i'd": 0.34; 'message.': 0.35; 'problem': 0.35; 'advice': 0.35; 'problem.': 0.35; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'method': 0.36; "i'll": 0.36; 'two': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'extremely': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'greatest': 0.60; 'tell': 0.60; 'numbers': 0.61; 'matter': 0.61; 'simple': 0.61; 'first': 0.61; "you've": 0.63; 'email addr:gmail.com': 0.63; 'information': 0.63; 'such': 0.63; 'provide': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'here': 0.66; 'between': 0.67; 'different.': 0.84; 'forced': 0.84; 'kennedy': 0.84; 'subject:Decision': 0.84; 'them)': 0.84; 'tie': 0.84; 'ranking': 0.96; '2013': 0.98
X-Virus-Scanned OK
Date Sun, 10 Nov 2013 18:26:07 -0800
From Gary Herron <gary.herron@islandtraining.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Help - Exercise Decision
References <3d585f7b-6e6c-46b8-94d9-33b4b30f11f8@googlegroups.com> <mailman.2356.1384130501.18130.python-list@python.org> <82597e09-1842-41ca-b7af-cb97dc40776f@googlegroups.com>
In-Reply-To <82597e09-1842-41ca-b7af-cb97dc40776f@googlegroups.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2361.1384136771.18130.python-list@python.org> (permalink)
Lines 156
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384136772 news.xs4all.nl 15871 [2001:888:2000:d::a6]:50205
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59045

Show key headers only | View raw


On 11/10/2013 04:48 PM, Kennedy Salvino wrote:
> Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron  escreveu:
>> On 11/10/2013 02:56 PM, kennedysalvino.ks@gmail.com wrote:
>>
>>> I'm trying to make a ranking of 3 numbers and say which the greatest and consider whether there is a tie between them, I am not able to make the conditions of draws.
>>> Code in PT-BR: http://pastebin.com/18pYJjPC
>>
>>
>> Please post the code directly in this message.  As a matter of
>>
>> safe-browsing practices, I won't follow that link.
>>
>>
>>
>> One tests for equality (draws as you call them) with the == operator.
>>
>> In what way does that not work for you?  Your question is so terse, that
>>
>> I'm not sure what you want.  Provide some examples please.
>>
>>
>>
>> Gary Herron
>
> Using only if elif else, here is the code



Holy HELL man, that's a lot of code for such a simple problem. But 
perhaps your assignment requires you to do it this way. (In which case 
I'd have a word with your teacher.)

But assuming you've got the sorting part correct, (which you don't quite 
-- the three numbers 2 1 3 entered in that order don't sort correctly), 
I'll guess the problem is in the 8 lines you have triple-quoted out, true?

The first of those lines won't do what I think you are trying to do. Try 
this instead (I'm using a, b, and c instead of your variables):
empate = a==b or a==c
Each == test produces a True/False value and the "or" combines the two 
into a single True/False. Your code
empata = a == b or c
does something much different.

That being said, I have to question what you are going to do with 8 such 
computations. A single test like
if a==b or b==c or a==c:
would tell you if any two of the three values are equal. Do you need 
more information than that?

And then I feel compelled to add one more comment: Your method of 
sorting three numbers is extremely wordy and inefficient. What part of 
that did you invent, and what part is forced on you by your teacher? Are 
you allowed to be “smarter” about it, and would you like some advice on 
that part?

Gary Herron



>
> primeira_pontuacao = int(input("Digite a primeira pontuação: "))
> segunda_pontuacao = int(input("Digite a segunda pontuação: "))
> terceira_pontuacao = int(input("Digite a terceira pontuação: "))
> '''
> empate = primeira_pontuacao == segunda_pontuacao or terceira_pontuacao
> empate2 = segunda_pontuacao == primeira_pontuacao or terceira_pontuacao
> empate3 = terceira_pontuacao == primeira_pontuacao or segunda_pontuacao
> empate4 = primeira_pontuacao == terceira_pontuacao != segunda_pontuacao
> empate5 = segunda_pontuacao == terceira_pontuacao != primeira_pontuacao
> empate6 = terceira_pontuacao == segunda_pontuacao != primeira_pontuacao
> empate7 = primeira_pontuacao == segunda_pontuacao == terceira_pontuacao
> '''
> colocacao1 = 0
> colocacao2 = 0
> colocacao3 = 0
>
> if (primeira_pontuacao > segunda_pontuacao):
>      if(segunda_pontuacao > terceira_pontuacao):
>          colocacao1 = primeira_pontuacao
>          colocacao2 = segunda_pontuacao
>          colocacao3 = terceira_pontuacao
>      else:
>          colocacao1 = primeira_pontuacao
>          colocacao2 = terceira_pontuacao
>          colocacao3 = segunda_pontuacao
> elif (segunda_pontuacao > terceira_pontuacao):
>      if(terceira_pontuacao > primeira_pontuacao):
>          colocacao1 = segunda_pontuacao
>          colocacao2 = terceira_pontuacao
>          colocacao3 = primeira_pontuacao
>      else:
>          colocacao1 = segunda_pontuacao
>          colocacao2 = primeira_pontuacao
>          colocacao3 = terceira_pontuacao
> elif (terceira_pontuacao > segunda_pontuacao):
>      if(segunda_pontuacao > primeira_pontuacao):
>          colocacao1 = terceira_pontuacao
>          colocacao2 = segunda_pontuacao
>          colocacao3 = primeira_pontuacao
>      else:
>          colocacao1 = terceira_pontuacao
>          colocacao2 = primeira_pontuacao
>          colocacao3 = segunda_pontuacao
> elif (primeira_pontuacao > terceira_pontuacao):
>      if(terceira_pontuacao > segunda_pontuacao):
>          colocacao1 = primeira_pontuacao
>          colocacao2 = terceira_pontuacao
>          colocacao3 = segunda_pontuacao
>      else:
>          colocacao1 = primeira_pontuacao
>          colocacao2 = segunda_pontuacao
>          colocacao3 = terceira_pontuacao
> elif (segunda_pontuacao > primeira_pontuacao):
>      if (primeira_pontuacao > terceira_pontuacao):
>          colocacao1 = segunda_pontuacao
>          colocacao2 = primeira_pontuacao
>          colocacao3 = terceira_pontuacao
>      else:
>          colocacao2 = segunda_pontuacao
>          colocacao3 = terceira_pontuacao
>          colocacao1 = primeira_pontuacao
> elif (terceira_pontuacao > primeira_pontuacao):
>      if(primeira_pontuacao > segunda_pontuacao):
>          colocacao1 = terceira_pontuacao
>          colocacao2 = primeira_pontuacao
>          colocacao3 = segunda_pontuacao
>      else:
>          colocacao1 = terceira_pontuacao
>          colocacao2 = segunda_pontuacao
>          colocacao3 = primeira_pontuacao
>
> print("O primeiro: " , colocacao1)
> print("O segundo: ", colocacao2)
> print("O terceiro: ", colocacao3)

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


Thread

Help - Exercise Decision kennedysalvino.ks@gmail.com - 2013-11-10 14:56 -0800
  Re: Help - Exercise Decision Gary Herron <gary.herron@islandtraining.com> - 2013-11-10 16:34 -0800
    Re: Help - Exercise Decision Kennedy Salvino <kennedysalvino.ks@gmail.com> - 2013-11-10 16:48 -0800
      Re: Help - Exercise Decision Gary Herron <gary.herron@islandtraining.com> - 2013-11-10 18:26 -0800
      Re: Help - Exercise Decision Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-11 02:59 +0000
  Re: Help - Exercise Decision Kennedy Salvino <kennedysalvino.ks@gmail.com> - 2013-11-11 03:55 -0800
  Re: Help - Exercise Decision Kennedy Salvino <kennedysalvino.ks@gmail.com> - 2013-11-11 03:55 -0800

csiph-web