I'm using Linux Mint 14 (Nadia) and Python 2.7.3. I can't get that 'Cube Root of a Perfect Cube" program working. It prompts me to enter an integer and when I do and hit enter, I go right back to the prompt. Anyone else with this problem?
edX CS50x Intro to CS I
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Did you try tossing in some print statments?
yes e.mccormick is right , to print something on screen you need to insert print statements in your code
Going back to the prompt without error means that program executed properly(even tough in this case did not gave the desired result i.e to print the answer)
Not the answer you are looking for? Search for more explanations.
Many programmers will make some sort of console dump or printout to debug things. There are tons of debugging tools, but the basic "print this variable at this instant" method has a serious advantage: It is very easy to do and does not rely on you managing to get the program to stop at just the right moment. I have had a loop print "in loop" at the top just to make sure it was actually looping... found out it was going in, but not looping, traced down the logic error, ran again and got tons of "in loop" messages so I knew that was fixed. Little things like that can be invaluable! So even if you don't print a variable, printing a message would let you know that Python was working.
and also, as Prof Guttag points out in his lecture on debugging, don't just output value for debugging purposes. When you're able (which you should always be) add more to the output to provide context. specifically what variable you're outputting and what you expect it to be. That will make discrepancies jump out at you even more and can save you from your own subliminal assumptions which can take hours to track down in complicated algorithms
and apparently this is an old thread, sorry for the accidental bump