Lab 2
- Part 1 Using the debugger
-
- Create a working directory e.g. lab2 and download the source files from Canvas. Create a PyDev project for this week or use an existing one.
- Import "isPrime.py" into the project created, right-click line 13 to set a breakpoint
- Click "Open Perspective" icon next to the search glass icon or Window->Perspective->Open Perspective->Other... to use the debugger
- Before launching the debugger to execute each line of code, type the expressions to examine their values at the breakpoint.
- Click the debugger icon or Run->Debug As->Python Run to launch the debugging process, enter any number in the input prompt e.g. 91
- Check if values of expression are as expected and click Resume button to continue the execution of the program
- Try to use different input and breakpoint to trace the program.
- Right-click the Debugger Perspective icon to close when finished.
- Part 2 CGI Python script and HTML
-
-
Install the XAMPP for Windows by Apache Friends
apachefriends.org
-
Find the XAMPP control panel from the Windows menu. Click it to start and you will see the below screen.
- Click the config button, Add .py to the "AddHandler cgi-script ..." line in the file "httpd.conf"
- save file and click the "start" button to start the Apache server
- Download the source files from week1 tutorial folder.
- Copy all "cgi*.py" to your "xampp/cgi-bin/" directory, copy "cgilogon.html" file to "xampp/htdocs/" directory
- Modify python location in first line of all "cgi*.py" file. Use IE to test all program.
- Part 2 Programming exercises.
-
- Here are 6 integers : 1, 7, 3, 2, 0, 5. Use diagrams to show the steps of sorting the integers into ascending order using bubble sort. Given "bubblesort.py" in Lab 2 tutorial folder, check your answer using breakpoint in Eclipse debugger.
- In "SBapp.py", sorting of Client List was done using Python sorted() method i.e. "sorted(clientDL, key = lambda c: c.name)". Modify bubblesort.py and use bubblesort() to do the sorting in "SBapp.py".
-
Test "SBapp.py" with the following data files and transactions:
Add the test cases to "SBappTestReport.html" and modify the program to fix the error. Identify the part of program code that causing the errors; add exception handling to handle all errors found.
- modify "cgilogon.py" to display a link to your personal web page or any other page of your choice.
Submit "cgilogon.py" after you finished.
- Change the loantable application to run on a server, and display the output in the browser as below.
Month | Starting Balance | Payment | Middle Balance | Interest | Ending Balanace |
1 | 300.00 | 100.00 | 200.00 | 2.00 | 202.00
|
2 | 202.00 | 100.00 | 102.00 | 1.02 | 103.02
|
3 | 103.02 | 100.00 | 3.02 | 0.03 | 3.05
|
4 | 3.05 | 3.05 | 0.00 | 0.00 | 0.00
|