UAT 104 Computer Programming

Worksheet 1 A mission calculator

Analysis activity 6 hAssesses CLO1

Objective

Set up a Python environment and write a first program comparing available flight time with the time the mission needs

Equipment and materials

  • Computer with Python 3.12–3.14
  • requirements.txt and example code at /downloads/uat-104/
  • VS Code or Jupyter Notebook
  • Battery specification of the group's chosen drone

Safety

  • Desk work only; no flying

Steps

  1. Install Python, create .venv and install requirements.txt
  2. Screenshot python --version and pip list
  3. Write mission_calc.py storing voltage, capacity, usable fraction, average power and distance as variables
  4. Print available and required flight time; test against Example 1 to get 24.4 minutes
  5. Switch to the group's drone and check whether the mission fits
  6. Open Jupyter, run Example 2 and explain the result in a text cell

Record of results

Table 1 Development environment check
Item checkedCommand usedResultPass?
Table 2 Output of mission_calc.py
Data setVoltage (V) and capacity (Ah)Usable energy (Wh)Available time (min)Required time (min)Mission fits?
Note 3 Explain the result of Example 2 in your own words

Questions

  1. Why must the program give 24.4 minutes for Example 1 before you enter your group's drone? If it printed 0.41 or 1461.4 instead, which line of the code would you suspect?

  2. How many minutes of margin does your group's drone have over the time the mission needs? If the usable fraction drops from 0.8 to 0.7, how much does the result change, and does the mission still fit?

  3. Why does total == 1.0 in Example 2 give False while math.isclose(total, 1.0) gives True? What would happen if a program checked sensor values with ==?

  4. Give two variable names from your group's mission_calc.py and explain which unit mistake each name helps prevent.

Check before you hand in

What to hand in

  • Environment screenshots
  • mission_calc.py
  • Notebook explaining Example 2

CLO1 Write structured Python programs to solve technology problems. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack