Problem Solving using Python Lab
Lab Assignment 4 (Python Debugging)
NOTE: All students must submit the programs (code with running output) of this assignment in a
single doc/pdf file to their respective faculty of Lab. Title of submission should be as
rollNumber_Group_Name_AssignmentNumber.doc/docx/pdf.
Q1 (a) Write a Python program to find the square and cube of a number.
(b) Pause the execution of above program and enter into interactive debugging using
1) pdb.set_trace(),
2) breakpoint() and
3) command line module (python -m pdb [Link])
Q2
(a) Write a Python program to find the maximum of three numbers.
(b) Demonstrate the use of step and next commands in the following program:
(c) Create 2 breakpoints in the above program using break command and demonstrate the
use of continue command.
(d) Disable breakpoints and show the enable/ disable status of breakpoints.
Q3 Create a list and tuple. Compare the equality of the created list and tuple. Show the error, if
any, using post mortem debugging.
Q4 Consider a Python expression (a + b * c - (d / e)).
(a) Take values of all variables input from user and print the result.
(b) Re-write the above expression to convert it into multiple line statement using “\”, (), [] and
{}.