AQA Green Fly Population Model

Verified

Added on  2019/10/09

|13
|3085
|564
Report
AI Summary
This report details the development of a program to model a green fly population. The student outlines the design, including flowcharts and pseudocode for a menu-driven system allowing users to set initial population values, run the model for a specified number of generations, and export the results. The report covers the implementation of subroutines for setting generation 0 values, displaying data, running the model, and exporting data to a file. Error handling and data validation are discussed. While the disease modeling aspect was not implemented, the report thoroughly documents the planned approach. The report showcases programming techniques such as input/output, subroutines, loops, conditional statements, type casting, error handling (try-except), list manipulation, and file I/O.
Document Page
AQA Green Fly Population
Section 1: Design
Row 1: Understanding the Tasks
Task 1
In 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 is
less 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 2
In 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 3
In 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 be
returned 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 4
In 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 5
In 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
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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 6
In 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.
Document Page
Row 3: Pseudo-code
Task 1: pseudo-code
PROCEDURE Menu
X 0
WHILE X==0:
OUTPUT “Treasure Hunt- Menu”
OUTPUT “1. SET gen 0 values”
OUTPUT “2. Display gen
values”
OUTPUT “3. Run module”
OUTPUT “4. Export data”
OUTPUT “5. Disease”
OUTPUT “6. Exit”
OUTPUT “Pick an option
number”
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 PROCEDURE
Task 1 is a sub-routine
that will print the menu
that will be shown to the
user. 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.
Document Page
Row 2: Overview
Task 1: Flowcharts
This 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.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Task 2: flowcharts
This flowchart will allow the user to
set the generation values. I have
used a long flow chart because it
would take too much time and even
more space to make smaller
subroutines. After this procedure is
complete the user will be returned
to the menu. The user will be asked
to input each survival rate and birth
Document Page
Task 3: Flowcharts
This flowchart is the “Display generation 0” subroutine. It will output
the list with all of the generation 0 values in the cells of the list under
the headings of “J”, “A”, “S”, and “T”; juveniles, adults, seniles and
total population. I have created a subroutine within a subroutine so
that I would not have a long chain of flowcharts and so that I can call
“display generation 0” and “display generation ()” separately.
Document Page
Task 4: Flowcharts
This flowchart is the “run module”
subroutine. It will output the new number
of juveniles, adults and seniles which will
be connected to a decision that checks if it
has repeated this process until it has
reached the number of generations the
user chose to create. It will do this by
multiplying the birth rate and survival rates
by the specific value and will save it as a
new variable in the code.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Task 5: Flowcharts
Section 2: Development
Row 1: Meeting the needs of the user
Task 1:
In this task I have created the menu, each option will correspond to a number. This means that the
user can pick a number instead of
typing and number for ease. This
means that I do not need to create
other variables that will allow capital
I have created a visual menu so that
the user can know what they are
choosing. I have printed it in a way
that it is aesthetically pleasing and
This is flowchart is the “export data”
subroutine. It will output a message asking the
user to choose a file name for the data that
they wish to export of save and will then check
if their chosen file name already exists with a
decision. If the file does exist it will ask the user
if they would like to overwrite the file, if the
user chooses to accept over writing the file;
new file will be saved over the old one.
However, if the user does not chose to over
write the file it would return to the beginning
of the subroutine. Also if the file does not
already exist; the file will be saved and the user
will return to the menu.
Document Page
and or lower case letters to be allowed which makes it much less difficult to code. If the user has
selected anything other than the options available, an error message will be displayed and the user
will be taken back to the menu.
This is how I have coded the input and output for the options from the menu.
Task 2:
In this task I have created subroutine called setgen0values that will allow the user to set the
generation 0 values for; the population numbers of juveniles adults and seniles, survival rates for
juveniles adults and seniles, the birth rate, number of new generations to model which has to be
between 5 and 25. If not, an error message will be displayed an they will have to input another
option.
This part of the code allows the user to input their data. I have made variables global so that they
can be recalled throughout the code, I have done it in this way because it is much easier to do and it
will not
take as
many lines
and time.
I have
saved these variables as floats so that they can be placed into a grid and can be changed within the
grid easily.
Document Page
I have also added another variable called new gen (new generation). This is so that the user can
select how many generations that they want to simulate. I used an if statement in order to test the
input that is given by the user.
This is the subroutine that will allow the user to input the starting number of juveniles, adults and
seniles and test it; If the number they input is not more than or equal to 0, two error messages will
be displayed using else and except and they will have to input another value. If the user inputs a
number that meets the criteria, it will be saved as a float and at the end all the numbers will be
printed out for the user to see.
This is the second part of the subroutine
that allows the user to set the birth rate,
survival rates for: juveniles, adults and
seniles. Each input is tried using a while
true loop and an if statement. If the
input meets the certain criteria, the
number will be saved as a float and then
the loop will break. However, if the
number does not meet the criteria, two
error messages will be displayed using
else and except. Once this subroutine is
complete the numbers will be printed
out for the user to see.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Task 3:
In this task I have created a subroutine called displaygen0values that allows the user to see the
generation 0 values that they have set for; juveniles, adults, seniles, survival rates and the birth rate.
All I have done is printed each value so that the user can see it. I have used the variable ‘alldata’ to
represent old juveniles, adults and seniles for ease
Task 4:
In this task I have created a subroutine called runmodule that will allow the user to run the module.
Firsty I had to initialise the generations. I then looped around for as many generations as I entered,
and referring to the previous generations data I calculated the new generations data and put it on to
the end of the data list.
Document Page
Task 5:
In task 5 I have created a subroutine called ‘exportdata’ that will allow the user to export data into
another document. I used a while statement that will test if the file name already exists, if it doesn’t
then it will name the file the chosen name. However, if the name already exists then the user will be
asked if they want to overwrite the file name. If yes, then the file will be overwritten. If no, the user
will be asked to input a new file name. I used the os.path.isfile to test if the file already exists.
Row 2: Tasks catered for
Insert a table – each task and yes or not if you’ve tried to do it
Task Catered for? Notes
1 Yes This was fully catered for
2 Yes This was fully catered for
3 Yes This was fully catered for
4 Yes This was fully catered for
4 Yes This was fully catered for
6 No I did not attempt this
Row 3: Code Listing
Send code to me when you’re happy with it I will make into JPGs for you
Section 3: Programming Techniques
Row 1: Techniques Used
Output (print)
Input
Importing External files
chevron_up_icon
1 out of 13
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]