Lab / Develop a simple Python application from a structure chart

This is requires that you turn a structure chart in Python code through the use of functions (subroutines).


All lab files for this practical activity are available in the 11SWE Practical Work GitHub repository. You can download starter files and additional resources to support your learning.

Overview

In this lab, you will implement a Python program that calculates the area and volume of different shapes using functions. You will create a structure chart, which breaks the program into modular subroutines. Your task is then to translate this chart into Python functions.

By the end of this lab, you will understand how to:

  • Develop and interpret a structure chart.

  • Write Python functions with parameters and return values.

  • Use modular programming to build a structured application.

Learning Objectives

By completing this lab, you will:

  • Implement functions in Python based on a structure chart.

  • Use parameters and return values to pass data between functions.

  • Develop a menu-driven program to allow user interaction.

  • Apply top-down design by structuring the program into smaller sub-problems.

Task Instructions

Step 1: Structure chart

  • Use the starter code in lab01_functions.py to create a structure chart for the program.

  • Upload your structure chart to your forked GitHub repository

Step 2: Implement the missing functions

  • Complete each of the functions to calculate area and volume.

Step 3: Test your functions

  • Run the program and choose different shapes.

  • Verify that the correct area or volume is displayed.

Step 4: Extend the program

  • Edit your structure chart to include an option for calculating the perimeter of suitable shapes.

  • Modify your code to include this function.

  • Add a loop to allow multiple calculations without restarting the program.

  • Add error handling for invalid inputs.

Last updated

Was this helpful?