Object oriented python programming Assume that you have been hired by a company
ID: 3721952 • Letter: O
Question
Object oriented python programming
Assume that you have been hired by a company that is developing an application for collecting and processing forest inventory data using a GPS unit that is capable of running Python scripts. (Many of them are…)
A. Develop a class called ‘Plot’ to hold information about forest plots and perform calculations. The variables that the class should hold are:
plot_ID: (This should be a string)
radius: (The radius of the plot (circular plots are typically used in forestry) )
units: (The units of the plot radius (it should allow the user to specify feet or meters) )
tree_count: (The number of trees found in the plot)
biomass: (The total biomass of the trees found in the plot (in kg))
The methods contained in the class should be the following:
__init__: (Sets up the different variables and assigns them to default values)
set_plot_ID: (Sets the ‘plot_ID’)
set_radius: (Sets the value of ‘radius’)
set_units: (Sets the value of ‘units’)
set_tree_count: (Sets the value of ‘tree_count’)
set_biomass: (Sets the value of ‘biomass’)
get_plot_ID: (Gets the ‘plot_ID’)
get_radius: ( Gets the value of ‘radius’)
get_units: (Gets the value of ‘units’)
get_tree_count: (Gets the value of ‘tree_count’)
get_biomass: (Gets the value of ‘biomass’)
get_area: (Gets the area of the plot in acres.) Note that there are 43560 ft2 in an acre, and there are 3.048 feet in a meter.
get_trees_acre: (Returns the number of trees per acre.) This is equal to the number of trees in the plot divided by the size of the plot in acres.
get_biomass_acre: (Returns the biomass per acre.) This is equal to the biomass in the plot divided by the size of the plot in acres.
The methods for setting of variables should be similar to one another, as will the methods for getting them.
B. Write a python program to test out the class you just made. It should prompt the user to enter data on 5 plots. Each plot should be an object based on the ‘Plot’ class you created. Have the user enter in the plot_ID, plot _radius, the units for the plot radius, the tree count for the plot and the biomass for the plot.
The program should then return:
1. the average trees per acre for all the plots and
2. the average biomass per acre for all the plots.
Explanation / Answer
The following code should help. The variable names are very much intuitive and self-explanatory:
Sample Output:
Enter Plot ID:plot1
Enter Radius of Plot:20
Enter the Units of Radius (feet or meters):feet
Enter Tree Count for plot:900
Enter Biomass for plot (in kg):1000
Enter Plot ID:plot2
Enter Radius of Plot:40
Enter the Units of Radius (feet or meters):meters
Enter Tree Count for plot:50
Enter Biomass for plot (in kg):20
Enter Plot ID:plot3
Enter Radius of Plot:120
Enter the Units of Radius (feet or meters):feet
Enter Tree Count for plot:700
Enter Biomass for plot (in kg):560
Enter Plot ID:plot4
Enter Radius of Plot:90
Enter the Units of Radius (feet or meters):meters
Enter Tree Count for plot:100
Enter Biomass for plot (in kg):600
Enter Plot ID:plot5
Enter Radius of Plot:50
Enter the Units of Radius (feet or meters):feet
Enter Tree Count for plot:840
Enter Biomass for plot (in kg):700
Average Tree Count per acre is:
7322.806983999263
Average Biomass per acre is:
7846.925159341708
Process finished with exit code 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.