Help - Exercise Decision
breamoreboy at yahoo.co.uk
Mon Nov 11 03:59:24 CET 2013
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
>>> On 11/10/2013 02:56 PM, kennedysalvino.ks at 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
More information about the Python-list