Interaction and debugging, Python Programming

 

We encourage you to adopt an interactive style of debugging and programming. Use the Python shell a lot. Write short pieces of code and check them.  It is much  simpler to test the individual parts as you go, rather than  to take hours writing a large program, and then search it does not work,  and must sift through all your program, trying  to search the bugs.

But, if you ?nd  yourself in the (inevitable) position of having a big program with  a error in it, do not despair. Debugging a program does not require brilliance or creativity or much  in the way of inside.  What it needs is a systematic and persistence approach.

First of all, have  a test case (a set of inputs to the procedure you are trying  to debug) and  know what  the answer is considered to be.  To check a program, you might  start  with  some  special  cases: what  if the argument is 0 or the empty function? Those cases may  be simpler to sort through ?rst (and are also cases that can be easy to get worse). Then try more specific cases.

 

Now,  if your  program gets your  test case incorrect, what  could you do?  Resist the temptation to start  changing your  program around, just to watch if that  will ?x the solution. Do not modify  any code until  you know  what  is wrong with  what  you are doing  now, and therefore seems that the modify  you make is going to correct the problem.

Ultimately, for debugging large programs, it is most useful  to use a software development environment  with  a serious debugger. But these  methods may sometimes have  a steep  explaining curve,  so in this class we will study to debug systematically using  "print" statements.

 

Posted Date: 8/9/2012 6:59:58 AM | Location : United States







Related Discussions:- Interaction and debugging, Assignment Help, Ask Question on Interaction and debugging, Get Answer, Expert's Help, Interaction and debugging Discussions

Write discussion on Interaction and debugging
Your posts are moderated
Related Questions
Bank transfer What  if we  have  two  values,  representing bank  accounts, and  need  to transfer an  amount of money  amt between them?  Consider that a bank account is show

inputWithinRange (prompt, lowValue, highValue) This function will ask for a number using the prompt parameter. The function will only return a value that is within the inclusive ra

how to calculate angle between 2 moving line in 2d space

List mutation and shared structure Lists are mutable data  structures, which defines  that  we can actually modifies  the values  stored in their components. We do this by usi

Primitives, Composition, Abstraction, and Patterns   We will  start  by thinking about  how  the  PCAP  framework applies to computer programs, in general. We may do that by

what is python

De?nition   A method de?nition has the abstract form: def ( , ..., ): ...   There are essentially three parts: is a name for

Tuples  and strings Python has two different more list-like data  types  that are very important to understand.A tuple  is a structure that  is like a list, but  is not  mutab

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

You should use for whenever you can, because  it creates  the structure of your  loops clear. Sometimes, however, you require to do an operation various times, but you don't want t