TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python Tutor: Visualize Code Execution

5 pointsby r4vikalmost 12 years ago

2 comments

mjhea0almost 12 years ago
<a href="http:&#x2F;&#x2F;www.pythontutor.com&#x2F;visualize.html#code=%23+Write+a+function,+power(),+that+takes+two+%0A%23+non-negative++integers,+base+and+exponent,+%0A%23+and+prints+the+base+raised+to+the+exponent+%0A%23+power.%0A%0A%23+Do+not+use+the+base+**+exponent+(2**4)+%0A%23+notation.%0A%0A%0Adef+power(base,+exponent)%3A%0A++++new_base+%3D+1%0A++++for+x+in+range(0,exponent)%3A%0A++++++++new_base+*%3D+base%0A++++print+new_base%0A%0Aprint+pow(3,10)+%3D%3D+59049&amp;mode=display&amp;cumulative=false&amp;heapPrimitives=false&amp;drawParentPointers=false&amp;textReferences=false&amp;showOnlyOutputs=false&amp;py=2&amp;curInstr=2" rel="nofollow">http:&#x2F;&#x2F;www.pythontutor.com&#x2F;visualize.html#code=%23+Write+a+f...</a>
dubertonalmost 12 years ago
awesome work!