Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59046
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Help - Exercise Decision |
| Date | 2013-11-11 02:59 +0000 |
| References | <3d585f7b-6e6c-46b8-94d9-33b4b30f11f8@googlegroups.com> <mailman.2356.1384130501.18130.python-list@python.org> <82597e09-1842-41ca-b7af-cb97dc40776f@googlegroups.com> <5280403F.6090404@islandtraining.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2362.1384138756.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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