Re: Help - Exercise Decision
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. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Exercise Decision
My teacher asked .. I will try to do as you said. -- https://mail.python.org/mailman/listinfo/python-list
Help - Exercise Decision
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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Exercise Decision
On 11/10/2013 02:56 PM, kennedysalvino...@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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Exercise Decision
Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron escreveu: On 11/10/2013 02:56 PM, kennedysalvino...@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) -- https://mail.python.org/mailman/listinfo/python-list
Re: Help - Exercise Decision
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...@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)
Re: Help - Exercise Decision
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...@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 -- https://mail.python.org/mailman/listinfo/python-list