Preliminary Software Engineering
Unit 1 - Programming Fundamentals
Unit 1 - Programming Fundamentals
  • 1 - Programming Fundamentals
    • Programming Fundamentals Content
  • 2 - Python
    • Expected Python Knowledge
    • GitHub
    • Learning Python
    • Data Structures and File Management
      • Data Structures
        • Lists
        • Arrays
          • Single and Multi-Dimensional Arrays
        • Lists vs Arrays
          • Activities
        • Tuples
        • Sets
        • Dictionaries
          • Activities
      • File Handling
        • Loops, Lists, Dictionaries
        • Activities
  • 3 - Theory Content
    • Theory Content Explained
      • NESA Directional Verbs
      • Responding to Directional Verbs
  • 4 - Software Development and Management
    • Approaches to Software Development
      • Waterfall Model
      • Agile Model
      • Summary: Waterfall vs Agile
      • Activities
    • Software Development Steps
      • Sample Exam Question
      • Requirements Definition
        • Understanding the Need
        • Key Questions to Ask
        • Examples
        • Activities
        • Sample Exam Question
      • Determining Specifications
        • Functional Specifications
        • Non-Functional Specifications
        • Activities
      • Design
        • Top-Down Design Approach
        • Bottom-Up Design Approach
      • Development
        • Optimising Code
      • Integration
        • Example: Payment Program
        • Activity
        • Application Programming Interface (API)
          • Example: OpenWeather API
          • Example: WeatherAPI
          • Activity: Prepare Spells
      • Testing and Debugging
        • Test Data
          • Activities
        • Testing the System
          • Activities
        • Debugging
          • Types of Errors
            • Activities
          • Python Debugger
            • Activities
          • VS Code Debugger
            • Activities
      • Installation
        • Activities
        • Sample Exam Question
      • Maintenance
  • Charts and Algorithms
    • Example: IPO Charts and Pseudocode
      • Activities
    • Algorithms, Flowcharts, Pseudocode
      • Pseudocode Activities
      • Flowchart Activities
      • Sample Exam Questions
    • Structure Charts
      • Activities
      • Sample Exam Questions
    • Data Flow Diagrams
      • Activities
    • Data Dictionaries
      • Activities
    • Decision Trees
      • Activities
      • Sample Exam Questions
    • Gantt Chart
    • Class Diagrams
      • Sample Exam Question
    • Storyboards
      • Sample Exam Question
  • Testing and Debugging
    • Test Data
      • Activities
    • Testing the System
      • Activities
    • Debugging
      • Types of Errors
        • Activities
      • Python Debugger
        • Activities
      • VS Code Debugger
        • Activities
  • Computational Thinking
    • Decomposition
    • Abstraction
    • Activities
  • Version Control
    • Git
    • GitHub
    • Activities
  • Number Systems
    • Binary Systems
    • Hexadecimal Numbers
    • Using Two's Complement
    • Activities
  • 5 - Assessment Task 1
    • Data Science Project
      • Before we Start
        • Setting up GitHub Repository
        • Setting Up Markdown Documentation
      • Examples of API Usage
        • Starter Code: NASA Scenario
        • Starter Code: Spell Book
        • Starter: Pokédex Explorer
        • Starter Code: Weather App
        • Example: OpenWeather API
        • Example: WeatherAPI
        • Example: Prepare Spells
    • Task Guide
      • Requirements Definition
      • Determining Specifications
        • Use Cases
      • Design
        • Gantt Chart
        • Structure Chart
        • Algorithms
        • Data Dictionary
      • Development
        • Comments vs DocStrings
        • UI - main.py
        • Create Python Module
          • Example: NASA Module
          • Example: WeatherFetch Module
          • Example: SpellBook Module
      • Integration
        • Example: Pokedex
      • Testing and Debugging
        • Commit Changes
      • Installation
      • Maintenance
    • Submitting Your Task
Powered by GitBook
On this page
  1. 4 - Software Development and Management
  2. Software Development Steps
  3. Testing and Debugging
  4. Debugging
  5. Python Debugger

Activities

Copy the following into a new Python file:

import pdb

def calculate_total(price, quantity):
    total = price * quantity  # Line 3
    return total  # Line 4

def apply_discount(total, discount):
    return total - (total * discount)  # Line 6

def main():
    price = 100
    quantity = 5
    discount = 0.1  # 10% discount
    total = calculate_total(price, quantity)  # Line 10
    total_after_discount = apply_discount(total, discount)  # Line 11
    print(f"Total after discount: {total_after_discount}")  # Line 12

pdb.set_trace()  # Pause the program here

main()
  1. Breakpoint and Next (n)

    1. Run the above code. When the debugger starts running, type 'n' and press enter on each line until you are finished debugging.

    2. Describe what happened.

  2. Single Line Stepping (s)

    1. Run the above code. When the debugger starts running, type 's' and press enter on each line until you are finished debugging.

    2. Describe what happened.

Describe

  • Provide characteristics and features.

  1. Compare the next (n) command with the step (s) command.

Compare

  • Show how things are similar or different.

  1. Watch, whatis and print (p)

    1. Run the above code. When the debugger starts running, type 's' and press enter for 8 lines in a row.

    2. Then, type 'whatis total'

    3. Then, type 'p total'

    4. Describe what happened.

  2. Compare whatis and print (p) commands.

Submit when Finished

Submit a screenshot of the above to Google Classroom when you are finished.#

PreviousPython DebuggerNextVS Code Debugger

Last updated 3 months ago