Designing with Python Assignment

Added on - 09 Oct 2019

  • 13


  • 3085


  • 110


  • 0


Showing pages 1 to 4 of 13 pages
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 thegeneration 0 values, run the model, export data or exit. For this I will I will create a function thatcreates 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 0values’ or ‘exit’ etc. so they will be able to input either and it will not be classified as an error if theydo. Also, if the user inputs ‘set the generation 0 values’ or ‘exit’ with any capitals it will be convertedinto lower case so that it can be valid in python, this is so that the user is not inconvenienced if theyhave the caps lock on for example. So, if the user does not input 1 or 2 etc., or ‘set generation 0values’ 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 valuesfor each variable. Will ask the user to input the starting number for each population. Which I willmake into a float, along with the survival rates and births rates. I will do this because as thepopulation is in thousands there can be a decimal number, so floats will be used so the program willnot crash or give inaccurate results. The number of new generations to model will be an integerbecause it will be a whole number between 5 and 25. I may make these variables global as this iseasier for me. When this module is done it will return to the menu. I will have to include somevalidation 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 valuesfor the no. of juveniles, seniles and adults and also the birth rates and survival rates. When the userhas 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 orsome formatting on my output.Task 4In this task I will create a subroutine that will display the updated version of the list with its contentswith the no. of juveniles, seniles and adults, which will be saved as floats as they can be decimalnumbers, as well as the total population size for each population from gen 0 to the user chosen endnumber 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 themenu so that the user can save their data onto another application with ease. The user will be askedwhat they would like to name the file in question, when they input the file name the program willcheck it to see if it is already and existing file. If the file already exits “File Already Exists” will beprinted and they will be asked to name the file again. However, they can chose to overwrite the filebut if they do not chose this either; they will be asked to name the file again. If the file name does
not already exist; the user’s data will be saved under the chosen name. After they have done thisthey 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. Thisdisease is to regulate the greenfly population when it reaches over a certain amount that will beselected by the user, which will also be stored as a float to avoid crashing or inaccurate results. Ineach generation the program will check if the greenfly population has reached its trigger point usingan if statement, and stop the disease by using an ELIF statement to see if the population has gonebelow the trigger point that will only kill adults and seniles. I will then extend my menu to have anoption that will allow the user to set the trigger point, which will be a trigger for the disease.
Row 3: Pseudo-codeTask 1: pseudo-codePROCEDURE MenuX0WHILE 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”ChoiceUSERINPUTIF Choice == “1” THENSet gen 0 valuesELIF Choice == “2” THENDisplay gen valuesELIF Choice == “3” THENRun moduleELIF Choice == “4” THENDiseaseELIF Choice == “5” THENExitX+=1END IFEND WHILEEND PROCEDURETask 1 is a sub-routinethat will print the menuthat will be shown to theuser. It will also printthe grid and start thegame if the playerselects option 1.However, if they selectoption 2 the menu willclose.
Row 2: OverviewTask 1: FlowchartsThis flowchart is the menu and leadsto all subroutines. When the userselects an option, the subroutine ofthe option that they have selectedwill run. When each subroutine iscompleted they will return to themenu. If no option is selected theywill be returned to the beginning ofthe process.
You’re reading a preview

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document