Ask a question from expert

Ask now

Designing with Python Assignment

13 Pages3085 Words564 Views
   

Added on  2019-10-09

Designing with Python Assignment

   Added on 2019-10-09

BookmarkShareRelated Documents
AQA Green Fly PopulationSection 1: DesignRow 1: Understanding the TasksTask 1In this task I have to create a menu that will allow the user to set the generation values, display the generation 0 values, run the model, export data or exit. For this I will I will create a function that creates a menu and then prints it. The user will be able to select either option by inputting either 1, 2, 3, 4 or 5. The number will be assigned to each option. I will keep the number as a string so there isless of a chance that there will be an error. I will also allow the user to input ‘set the generation 0 values’ or ‘exit’ etc. so they will be able to input either and it will not be classified as an error if they do. Also, if the user inputs ‘set the generation 0 values’ or ‘exit’ with any capitals it will be converted into lower case so that it can be valid in python, this is so that the user is not inconvenienced if they have the caps lock on for example. So, if the user does not input 1 or 2 etc., or ‘set generation 0 values’ or ‘exit’ etc. python will output ‘That is not an option’ and they will have to input another.Task 2In this task I will have to create a subroutine that will allow the user to set the generation 0 values for each variable. Will ask the user to input the starting number for each population. Which I will make into a float, along with the survival rates and births rates. I will do this because as the population is in thousands there can be a decimal number, so floats will be used so the program will not crash or give inaccurate results. The number of new generations to model will be an integer because it will be a whole number between 5 and 25. I may make these variables global as this is easier for me. When this module is done it will return to the menu. I will have to include some validation in case the data the user inputs is not valid.Task 3In this task I will have to create a subroutine that will display the array with the generation 0 values for the no. of juveniles, seniles and adults and also the birth rates and survival rates. When the user has selected the generation 0 values, they will be saved and stored in the array and then they will bereturned to the menu. I will have to make sure I line everything up in a table so I might use pprint or some formatting on my output.Task 4In this task I will create a subroutine that will display the updated version of the list with its contents with the no. of juveniles, seniles and adults, which will be saved as floats as they can be decimal numbers, as well as the total population size for each population from gen 0 to the user chosen end number of generations. After this subroutine is completed the user will be returned to the menu. Task 5In this task I will create a subroutine that will have an export attribute that can be accessed form the menu so that the user can save their data onto another application with ease. The user will be asked what they would like to name the file in question, when they input the file name the program will check it to see if it is already and existing file. If the file already exits “File Already Exists” will be printed and they will be asked to name the file again. However, they can chose to overwrite the file but if they do not chose this either; they will be asked to name the file again. If the file name does
Designing with Python Assignment_1
not already exist; the user’s data will be saved under the chosen name. After they have done this they will be returned to the menu. Task 6In this task I will create a subroutine that will include a disease that will affect the greenflies. This disease is to regulate the greenfly population when it reaches over a certain amount that will be selected by the user, which will also be stored as a float to avoid crashing or inaccurate results. In each generation the program will check if the greenfly population has reached its trigger point using an if statement, and stop the disease by using an ELIF statement to see if the population has gone below the trigger point that will only kill adults and seniles. I will then extend my menu to have an option that will allow the user to set the trigger point, which will be a trigger for the disease.
Designing with Python Assignment_2
Row 3: Pseudo-codeTask 1: pseudo-codePROCEDURE Menu X 0 WHILE X==0: OUTPUT “Treasure Hunt- Menu” OUTPUT “1. SET gen 0 values” OUTPUT “2. Display genvalues” OUTPUT “3. Run module” OUTPUT “4. Export data” OUTPUT “5. Disease” OUTPUT “6. Exit” OUTPUT “Pick an optionnumber” Choice USERINPUT IF Choice == “1” THEN Set gen 0 values ELIF Choice == “2” THEN Display gen values ELIF Choice == “3” THEN Run module ELIF Choice == “4” THEN Disease ELIF Choice == “5” THEN Exit X+=1 END IF END WHILE END PROCEDURETask 1 is a sub-routine that will print the menu that will be shown to theuser. It will also print the grid and start the game if the player selects option 1. However, if they select option 2 the menu will close.
Designing with Python Assignment_3
Row 2: OverviewTask 1: FlowchartsThis flowchart is the menu and leads to all subroutines. When the user selects an option, the subroutine of the option that they have selected will run. When each subroutine is completed they will return to the menu. If no option is selected they will be returned to the beginning of the process.
Designing with Python Assignment_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
SIT105 Critical Thinking and Problem Solving | Report
|9
|1576
|285

LLOYDS BANK ACCOUNT SYSTEM.
|3
|497
|414

UNIX Script Assignment: Part 2 - NIT1202 Operating Systems
|9
|840
|374

Computer Science Assignment Pseudocode
|9
|895
|315

CLDA Loan Management Application: View, Request, Sort and Accept Loans
|14
|3975
|327

BookStore Application - Assignment
|38
|4445
|25