- Interactive Mode: It executes each line when you press enter.
- Script Mode : Write program, save the program and then run the program and get the output.
Writing a python program in script mode:
- Click on Start→All Programs→Python 3.7→IDLE (Python 3.7 32-bit). Python IDLE screen appears.
- Now click on File→New option.
- Write code for the program. Here I have written following code:
A simple program.
- Save the program.
Steps to Debug:
- Open Python IDLE.
- Click on Debug → Debugger option.
Debug on Python
- It will open a new window with the title “Debug Control” as displayed in this screen.
- Now click set the watch window position in such a way there you can look in the Python IDLE screen and watch window both.
- Now move on IDLE screen and Click on File→Open menu to open the written program.
- When program window appears, run the program. Click Run→Run Module option.
- It will activate disabled buttons such as Go, Step, Over, Out, Quit.
- Click on step button until it gets disable, when it gets disabled enter desired input in IDLE window.
- Again click on step button to for another input. (Repeat these steps for all input functions and enter values)
- Observe the watch window to view the value of variables with relevant changes.
Under stand with this program.
My first watch window after click on Debug.
- As you can see python program main function is highlighted in blue color i.e. _main_ with function header def fun1(x,y) when you run the program.
- If you want to see the line where cursor is placed click on source check box in watch window. Now when you click on step button, cursor will jump to line 5 for input as displayed in the following screen with highlighted blue color.
- Click on step again and again it will open run.py built-in module for write function, then readline() function, until all buttons in watch window gets disabled.
- When it will get disable python IDLE screen prompt the input message. Feed your data as prompted and do repeat the similar steps for another input function.
- After that repeat click on step to see the execution flow, the cursor moves in function fun1(a,b) with values are displayed in the watch window, look in this screen.
- After getting this screen, click on step button, cursor moves to first statement (highlighted in screen shot) of fun1(a,b) function as displayed in this screen.
- Now click on step one more time, you will get screen like this:
- Click on step to get this:
- Now click step button, the cursor will jump to main function and execute first output line. Repeat few clicks on step button and observe the result.
If you want to skip some internal function execution process click on over button. So it jumps directly to the statements written in a program.