Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 17 Online
OpenStudy (anonymous):

There's an error in the second part of the code sheet : http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-1/lecture-2-core-elements-of-a-program/MIT6_00SCS11_lec02.pdf To be exact : if x < y: if x < z: print 'x is least' else: print 'z is least' else: print 'y is least' Am I the only one getting wrong answers with this code ??? Thank you

OpenStudy (anonymous):

enclose your code in back ticks ``` or use a code pasting site like http://dpaste.com

OpenStudy (anonymous):

What is the error?

OpenStudy (anonymous):

Yeah, it's wrong because it doesn't check the value of z if x<y. The code should give the right answer if you use a "elif" statement on that second else, like in the block right after the one you posted, on the sheet. That's why these sheets don't make sense outside of the lectures. :P

OpenStudy (anonymous):

Ah ok, it's just he didn't talk about it at all. Thank you !

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!