

Press F7 repeatedly until you see the expression factorial(4) in the focus box. Luckily, Thonny can explain this concept intuitively without sweeping important details under the carpet.Ĭopy following recursive program into Thonny and run it in debug mode ( Ctrl+F5 or Ctrl+Shift+F5). Understanding parameter passing, local variables, returning and recursion all benefit from the notion of stack frame. Turns out the “jump model” is sufficient only with the simplest functions. Is it the whole story? Do we need to care? Traditional debuggers show us that when you step into the call, the focus jumps into the function definition (and later magically back to the original location).
#CONDITIONALS IN THONNY CODE#
On the surface there is nothing complicated - you give name to a code and refer to it (call it) somewhere else in the code. Does it look like something which understands the purpose of your code or more like a dumb machine following simple rules? Function callsįunction call is a programming concept which often causes great deal of confusion to beginners. You should see a triangle made of periods appear in the shell pane.Ĭontinue pressing F7 and observe how Python moves forward with really small steps. Copy following program text into the editor and save it into a file (Ctrl+S). When first launching Thonny, it does some preparations and then presents an empty editor and the Python shell.
#CONDITIONALS IN THONNY INSTALL#
Install it with sudo dnf install thonny or with a graphical tool of your choice (such as Software). Thonny is included in Fedora repositories since version 27. Thonny is a beginner-friendly Python IDE, developed in University of Tartu, Estonia, which takes a different approach as its debugger is designed specifically for learning and teaching programming.Īlthough Thonny is suitable for even total beginners, this post is meant for readers who have at least some experience with Python or another imperative language. Unfortunately, most debuggers are optimized for professional usage and assume the user already knows the semantics of language constructs (e.g. Programmers usually tackle this situation with a tool called a debugger, which allows running their program step-by-step. Commonly, this means you overlooked something or misunderstood a language construct, and you need to locate the place in the code where your expectations and reality diverge. Even when you finally get your colons and parentheses right, there is still a big chance that the program doesn’t do what you intended.
