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


Groups > comp.lang.python > #59030 > unrolled thread

Help - Exercise Decision

Started bykennedysalvino.ks@gmail.com
First post2013-11-10 14:56 -0800
Last post2013-11-11 03:55 -0800
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  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

#59030 — Help - Exercise Decision

Fromkennedysalvino.ks@gmail.com
Date2013-11-10 14:56 -0800
SubjectHelp - Exercise Decision
Message-ID<3d585f7b-6e6c-46b8-94d9-33b4b30f11f8@googlegroups.com>
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

[toc] | [next] | [standalone]


#59036

FromGary Herron <gary.herron@islandtraining.com>
Date2013-11-10 16:34 -0800
Message-ID<mailman.2356.1384130501.18130.python-list@python.org>
In reply to#59030
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

[toc] | [prev] | [next] | [standalone]


#59037

FromKennedy Salvino <kennedysalvino.ks@gmail.com>
Date2013-11-10 16:48 -0800
Message-ID<82597e09-1842-41ca-b7af-cb97dc40776f@googlegroups.com>
In reply to#59036
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

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)

[toc] | [prev] | [next] | [standalone]


#59045

FromGary Herron <gary.herron@islandtraining.com>
Date2013-11-10 18:26 -0800
Message-ID<mailman.2361.1384136771.18130.python-list@python.org>
In reply to#59037
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)

[toc] | [prev] | [next] | [standalone]


#59046

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-11-11 02:59 +0000
Message-ID<mailman.2362.1384138756.18130.python-list@python.org>
In reply to#59037
On 11/11/2013 02:26, Gary Herron wrote:
> 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
>
>

Regardless of the way the OP goes about it the use of print functions or 
a debugger wouldn't go amiss.

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#59069

FromKennedy Salvino <kennedysalvino.ks@gmail.com>
Date2013-11-11 03:55 -0800
Message-ID<59d1734f-4c7e-45e3-96d1-409d03e0b5d9@googlegroups.com>
In reply to#59030
Em domingo, 10 de novembro de 2013 19h56min45s UTC-3, Kennedy Salvino  escreveu:
> 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

My teacher asked .. I will try to do as you said.

[toc] | [prev] | [next] | [standalone]


#59070

FromKennedy Salvino <kennedysalvino.ks@gmail.com>
Date2013-11-11 03:55 -0800
Message-ID<30d7ecdf-674a-46ab-93e4-262daa3582b3@googlegroups.com>
In reply to#59030
My teacher asked .. I will try to do as you said.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web