UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
1 | P a g e
Instructions
This assignment will test your knowledge and skills in writing an application software for a task,
understanding the business rules of a particular problem, coding these in a computer program,
developing a graphical user interface, and reading data from a text file from a disk. As such, the
assignment requires you to integrate and synthesise what you have learnt so far in this unit, in order
to design and create a proper working solution.
Background:
The context of this programming assignment is free for you to choose. Think about any problem you
may be facing that is suitable to be tackled from an IT-programming perspective. I have chosen a case
study to show you how would you approach the problem from the very beginning, the compulsory
elements need to be included in your solution, and the final (and hopefully nice and useful) product.
This Assignment has three parts:
• Part 1: Use the problem-solving process to create a simple Python program using an
interactive text-based menu (no GUI)
• Part 2: The same as part 1, but wrapped in a graphical user interface (GUI)
• Part 3: The input comes from a text file – read only once, then information stored in a suitable
data structure.
An example case study is in page 2, it shows the integration of these three stages. Please bear in mind
that this is an example only. Your solution does not need to be exactly the same as this one. However,
be sure that you include every single element described at the end of each part. Allocated marks are
shown at the end of each part. Comments are shown in bold blue.
Submission
• This is a SOLO ASSIGNMENT.
• This assignment requires you to complete Python code written in .py modules, in addition to
supporting files.
• Create a folder called “uxxxxx_Assignment 3” and drop all your files in there (problem-solving
process answers, flowcharts, Word documents, and the like). Python modules are compulsory.
No modules, no marks.
• Compress (zip) ALL your files and folders created above in one single file called
uxxxxx_Assignment3.zip. Upload this file on Canvas by the due date using the drop box
provided in the corresponding module.
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
2 | P a g e
The Example Case Study
Planetary Exploration App
Credits: NASA Solar System Exploration @solarsystem.nasa.gov
PART 1: Problem-solving process to create a simple Python program via the Shell.
I Background
Our astronauts are about to leave for a trip to outer space. They may be visiting the Moon, Mercury,
Venus, Mars or one of the larger moons of Jupiter (IO, Europa, Ganymede or Callisto). Each astronaut
has a mass allowance in kg for items that they can take along the trip, including tools and personal
items. The amount they are allowed depends on their job description as follows:
Flight Crew are allowed a total of 100kg, and Mission Specialists are allowed a total of 150kg.
Each of the solar system bodies (celestial bodies) has less gravity than the earth. For example, if a mass
of 100kg on earth weights 100kg, on the Moon will weigh the equivalent of 16.6kg.
II Business Rules
a) The Problem at Hand
We need to calculate how much mass each astronaut has left over for personal items, the total
available mass and the average available personal mass allowance across all six astronauts. We need
to also calculate the weight of the average available personal mass allowance on the celestial body
the astronauts are travelling to. We assume there are three crew astronauts and three mission
specialists. Be sure to clearly state your assumptions!!!
b) Describing Inputs and Outputs
We need a list that contains the names of the celestial bodies that our astronauts may travel to and
their Mass multipliers. This list must be stored using an appropriate data structure. Do not hard-code
this table. This list is part of our inputs.
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
3 | P a g e
Celestial body Mass Multiplier
Mercury 0.378
Venus 0.907
Moon 0.166
Mars 0.377
Io 0.1835
Europa 0.1335
Ganymede 0.1448
Callisto 0.1264
Also, the user needs to decide which celestial body the astronauts are travelling to, alongside their
mass (Second set of inputs).
The code will display a list of celestial bodies that are possible destinations along with their mass
multipliers. Our code needs to also display the weight allowances for the two different types of
astronaut (All of these are our outputs).
III Develop a “Hand” Calculation
We will create (pure creation, that it is!!!) a flowchart to start with.
A flowchart consists of special symbols connected by arrows. Within each symbol is a phrase
presenting the activity at that step. The shape of the symbol indicates the type of operation that is to
occur. The arrows connecting the symbols, called flowlines, show the progression in which the steps
take place. Below is the ANSI standard for flowchart symbols (American National Standards Institute)1
:
1
“An Introduction to Programming Using Python”, Schneider, D.I. Pearson, 2016
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
4 | P a g e
Once finishing with our flowchart, we’ll develop a “pseudocode”, which is an abbreviated version of
actual computer code (hence, pseudocode). The geometric symbols used in flowcharts are replaced
by English-like statements that outline the process. As a result, pseudocode looks more like computer
code than does a flowchart. Pseudocode allows the programmer to focus on the steps required to
solve the problem rather than on how to use the computer language.
Ok then; let’s start with the flowchart according to the problem at hand and input/output (I/O)
description:
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
5 | P a g e
The above flowchart clearly shows the sequence of tasks that our program will be undertaking. We
now translate this flowchart into a pseudocode:
Program: Calculate Astronauts’ Mass Allowance
start
Print welcome message on the screen
Print (display) the menu on the screen
If [option A] then
print destination on the screen.
Else [option B]
print weight allowances.
Else [option C]
Input destination
input mass and personal items each crew member.
Calculate personal allowable mass for each crew member as:
Formula here [use functions for your calculations]
Print personal mass for each crew member.
Else [option D]
print weight allowances.
Input destination
input mass and personal items each crew member.
Calculate average allowable mass for crew members as:
Formula here [use functions for your calculations]
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
6 | P a g e
Print average mass for crew members.
Print exit message
end
A running example will be shown during the lectures.
Hint: Developing a Command-Line menu.
Step-by-Step Guide for Stage 1 (using the case study as an example)
1. Think about your strategy on how you will display the options for user to choose from
according to your flowchart. How you will calculate the available personal item mass for each
astronaut and how to calculate the average available mass and average available weight.
Think about writing simple functions for the repetitive calculations.
2. Create a new Python file, you may call it ProgAsgStage1
3. In the Stage1 class (file ProgAsgStage1.py), you may put all code for the user interaction
and the calculation into the main method. (You might still need to define global variables and
constants outside the main method at the top of the editor window). You might like to use
nested lists to hold the name and mass multiplier of the celestial bodies.
4. You will need to write a function to print a menu to the user. One possible example is:
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
7 | P a g e
5. Now add the code that implements your strategy to display the different destinations with
their mass multipliers, TEST.
6. Add the code to display the weight allowances for the two different types of astronaut, TEST.
7. Add the code to calculate the personal mass allowances of each of the six astronauts along
with the total available mass, TEST.
8. Add the code to calculate the average available mass allowance and weight on destination,
TEST.
9. Finally, add print statements to print the output to the user.
10. Test your implementation with the test cases mentioned below (and additionally your own).
For steps 7 & 8 work out your tests before you do any coding
Examples of Test cases:
Test 1
Destination Selected The Moon
Entered tool weights for crew 100, 100, 100
Entered tool weights for mission specialists 150, 150, 150
Available mass for astronauts: 0,0,0,0,0,0
Total Available Mass 0 kg
Average available mass: 0.0 kg
Average available weight on destination 0.0 kg
Test 2
Destination Selected Mars
Entered tool weights for crew 90, 90, 90
Entered tool weights for mission specialists 140, 140, 140
Available mass for astronauts: 10,10,10,10,10,10
Total Available Mass 60 kg
Average available weight 10 kg
Average available weight on destination 3.77 kg
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
8 | P a g e
Test 3
Destination Selected Venus
Entered tool weights for crew 99, 98, 101
Entered tool weights for mission specialists 150, 149, 151
Available mass for astronauts: 1,2,-1,0,1,-1
Total Available Mass 2 kg
Average available mass: 0.333333 kg
Average available weight on destination 0.302333 kg
Marks allocated for Part 1: [Total Marks: 60]
I Background [MARKS: 3 marks for a suitable background about the context of your problem]
II Business Rules
a) The Problem at Hand [MARKS: 3 marks for a clear and specific description of the problem to
be solved]
b) Describing Inputs and Outputs [MARKS: 3 marks for a clear and specific description of inputs
and outputs]
III Develop a “Hand” Calculation [MARKS: 3 marks for an example of manual calculations, 5 marks
for the flowchart, and 3 marks for the pseudocode.]
III Menu deployment
• Constants vs literals. Using constants is important for the ease of maintenance. Not using
constants will result in lower marks. For example, in this case study we consider constants for
the mass multipliers for each celestial body and the upper limit for each type of astronaut. [3
marks]
• Good names for your variables and constants. Check style against the Python style guide
attached below. [3 marks]
• The program must have at least one mathematical calculation. [3 marks]
• You must use functions for each task in your code, for example a printMenu function to
print a menu and calculateAverageMass to calculate the average available mass. [3 marks]
• Your program must have a main() function to appropriately direct the program. [2 marks]
• Program code layout. Separate blocks of code by a blank line. [2 marks]
• Program is written using well-defined functions including a main() function to direct the
program. [4 marks]
• Use of comments. A comment is not an essay. Comments are important for the maintenance
of a program and should contain enough details but keep them concise. Do not comment
every single line. [2marks]
• The program must have a short introduction. Check style against the Python style guide
attached below. [3 marks]
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
9 | P a g e
• The program must work correctly. That is:
o A text-based menu is displayed when first running your program. [5 marks]
o The menu works properly. [3 marks]
o Calculations are correctly performed. [3 marks]
o The output on the shell is properly formatted.
• Business rules are met. That is, your code solves the problem you are proposing (or at least
contributes to its solution). [4 marks]
Part 2. Developing a Graphical User Interface (GUI)
In Part 1, the user input and output was not very satisfactory from the human computer interaction
and usability point of view, your task in this part is to design and implement a Graphical User interface
(GUI) using buttons and labels that provides an easy to use interface.
Use the same code for the calculations from Part 1. Reusing code is an important part of software
development.
You have a great degree of freedom in what GUI elements you choose and how you would like to
design the layout of your GUI. What matters is the functionality of the design and that the user can
input the required data in a sensible fashion. However, some elements are compulsory, as we need to
assess your understanding of performing a suitable GUI.
Marks allocated for Part 2: [Total Marks: 30]
Your GUI application must allow a user to input various data elements. To this end, your GUI must:
• Use the Grid element [2 marks]
• Add Label elements throughout your GUI. [2 marks]
• Use the Background Colour property. [2 marks]
• Allow a user to select choices from an either list box, drop-down menu, or scroll-down menu
element. [2 marks]
UNIVERSITY OF CANBERRA
INTRODUCTION TO INFORMATION TECHNOLOGY (4478/8936)
ASSIGNMENT 3: Programming with Python
10 | P a g e
• Allow a user to input the data using an entry widget. [2 marks]
• Output data using an entry widget. [2 marks]
• Allow a user to click on a Calculate button that triggers any calculation. [2 marks]
• Allow a user to press an Exit or Quit button to properly close the program. [2 marks]
• GUI Design. Is it simple to use and easy to understand? [2 marks]
• Program is written using well-defined functions including a main() function to direct the
program. [2 marks]
• Program code layout. Separate blocks of code by a blank line. [2 marks]
• Separate GUI functionality from calculations. You should use a separate method for the
calculations. It is good practice and follows good programming style to separate GUI code
from other code. [2 marks]
• Use comments [2 marks]
• The program must have an introduction. Check style against the Python style guide attached
below. [2 marks]
• Business rules are met. That is, your code solves the problem you are proposing (or at least
contributes to its solution). [2 marks]
Part 3. Reading from an external file
Your task will be to add code to your Stage 2 program that reads an external .txt file (in our case study,
the astronaut tool weight data), put these into appropriate storage in memory (I suggest you use a
nested list) and display the details to user when requested. Please note that the text file needs to be
written by yourself according to your proposed problem. You can use any text editor such as Notepad
(do not use Word!!!) You should also use the advanced Python GUI components to create a graph to
show some of your calculations (compare the mass multipliers of the different destinations in our case
study)
During the lecture, I’ll go through the file astronaut.txt that contains the astronaut tool allowance
weights along with their destination. Each line consists of destination as the first element, followed by
a comma, that destination’s mass multiplier followed by comma and the weight of each astronaut’s
tools in kilograms (kgs).
Moon,0.166,92,93,90,135,140,143
Also, for our case study:
• Celestial body (destination) will be displayed to the user in ascending order of mass multiplier.
• The text file will be read once.
• We will write a function called readFile to read the data from the text file.
Marks allocated for stage 3: [Total Marks: 10]
• The test file is properly written according to the problem proposed [3.5 marks]
• The text file should only be read once. You probably want to do that at the start of the
program. Consider how you would do that. [3.5 marks]
• Correct display of data based on the details in the text file. [3 marks]
请加QQ:99515681 邮箱:99515681@qq.com WX:codinghelp
标签: