Programming with Python
Programming with Python
项目类别:计算机

Hello, dear friend, you can consult us at any time if you have any questions, add  WeChat:  zz-x2580


INTRODUCTION TO INFORMATION TECHNOLOGY

ASSIGNMENT 3: Programming with Python

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 maybe 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.

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.

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):

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:


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]

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:

 

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.

留学ICU™️ 留学生辅助指导品牌
在线客服 7*24 全天为您提供咨询服务
咨询电话(全球): +86 17530857517
客服QQ:2405269519
微信咨询:zz-x2580
关于我们
微信订阅号
© 2012-2021 ABC网站 站点地图:Google Sitemap | 服务条款 | 隐私政策
提示:ABC网站所开展服务及提供的文稿基于客户所提供资料,客户可用于研究目的等方面,本机构不鼓励、不提倡任何学术欺诈行为。