Comprehensive notes on Debugging Python Program class 11

In this article, we are going to discuss Comprehensive notes on Debugging Python Program class 11. Let’s start!

Comprehensive notes on Debugging Python Program class 11

Its always better to taste recipe you made before serving. If any thing is there it can be improved and get satisfaction for serving it to the people. This concept is similarly applied to programming also. 

A program written in python is interpreted by the python interpreter line by line. A program may have few errors except syntax error. Sometimes program may produce the garbage results. In this case, to understand the logical errors user need to check the program. This checking is known as debugging.  Debugging also help to understand how the program is working. In this post, you can read how to debug and test the program with python IDLE.

There are two ways of writing programs in python:

  1. Interactive Mode: It executes each line when you press enter.
  2. Script Mode : Write program, save the program and then run the program and get the output. 

Writing a python program in script mode

  1. Click on Start→All Programs→Python 3.7→IDLE (Python 3.7 32-bit). Python IDLE screen appears. 
  2. Now click on File→New option.
  3. Write the code for the program. Here I have written following code:
python code for class 11 students
python code for class 11 students

4. Save the program.

Now in the next section of Debugging Python Program class 11 we will talk about steps to debug.

Steps to Debug

  • Open Python IDLE.
  • Click on Debug → Debugger option.
debug in python
debug in 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 the 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 disabled when it gets disabled enter desired input in the IDLE window.
  • Again click on the 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.

After this understanding let us see the steps for the Debugging Python Program class 11.

Understand with this program.

python program
python program

So follow these instructions for Debugging Python Program class 11. My first watch window after click on Debug.

debug control window
  • 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.
debug control window 1
  • Click on the step, again and again, it will open run.py built-in module for write function, then readline() function, until all buttons in the 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 a 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, the cursor moves to first statement (highlighted in the screen shot) of fun1(a,b) function as displayed in this screen.
debug control 2
debug control 2

These steps for Debugging Python Program class 11 are very important to check the values while program debugging.

Now click on step one more time, you will get screen like this:

debug control window 3
debug control window 3

Click on step to get this:

step in python code
step in python code

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.

That’s all from this article Debugging Python Program class 11.

Comment Your Views

%d bloggers like this: