Python Lab 6: Timber Regrowth
Due Tuesday, October 12th, by 11:45pm
Introduction
To get started, open IDLE and then create a New File via the File menu. We
suggest you immediately save this file in the directory managing all
your Python Labs this semester. Please save this file with the following name:
Lab6-timber.py.
Assignment
A problem that occurs in timber management is determining how much of an area to leave
uncut so that the harvested area regrows in a certain period of time. It is assumed that
the natural process of reforestation takes place at a known rate per year, depending on
climate and soil conditions.
A reforestation equation expresses this growth as a function
of the amount of timber standing and the reforestation rate. For example, if 100 acres
are left standing after harvesting and the reforestation rate that year is 0.05 acres per year,
then 5 new acres of forest returns after the first year due to the natural process of
reforesting. In other words, 100 + 0.05 * 100 = 105 acres
of land are in the forest at the end of the first year. At the end of the second year,
the number of acres in the forest is
105 + 0.05 * 105, or 110.25 acres. In short, the reforestation
equation for this example is
( X * 1.05 ) where X is the acres of forest left standing.
In this lab, suppose 3,000 acres of land remain uncut and that the reforestation rate is
0.03 acres per year. Also assume 12,000 acres of land are
available in the area.
Your program should print a table that shows (1) the number of acres in the forest at
the end of each year for a total of Y years, where Y is entered by the user, and
(2) the % of the total area that has forest coverage
each year. Have your output organized in a nice table-like format, and include
year zero. (Hint: maybe use %.2f' for two decimal places.)
Extra credit (2 points): Modify your program to also output
how many years are required for the total area to be reforested, i.e.,
to restore the forest to 100% coverage. If you choose to do this, add one
more line to your output, e.g., "OUTPUT 52" (52 is not the correct answer).
You can assume the input to your program is always valid (i.e., the number of
years is an integer greater than zero).
Lab I/O Format
Throughout this semester we use a specific Lab Input/Output Format.
This format is described below:
- When prompting for input, use the prompt string
WORD> , where
WORD is a single, uppercase word which
describes the input. For example, this lab might choose:
YEARS> .
- When providing output that will be graded, start the line with
OUTPUT . Think of this as "boxing your
answer" on a math worksheet; it lets us quickly find your
answer. Our grading script will skip any output lines that do
not start with OUTPUT .
- You are welcome (and should!) have other output lines that do
not begin with OUTPUT; while our grading
script will ignore these, good programmers include print
statements that are informational to the user of the program.
- A submission without exactly correct output formatting will receive an
AUTOMATIC ZERO. This is because Gradescope is automated—it does not
look at your code, only the results, and thus the format of the results must
be consistent for all students.
Example Execution
Input the number of years to print in the reforestation table:
YEARS> 5
The reforestation table is then
Year, # Acres, % of Forest
OUTPUT 0, 3000.0, 25.00%
OUTPUT 1, 3090.0, 25.75%
OUTPUT 2, 3182.7, 26.52%
OUTPUT 3, 3278.2, 27.32%
OUTPUT 4, 3376.5, 28.14%
OUTPUT 5, 3477.8, 28.98%
Gradescope Submission Nuances
When you submit your Python file to Gradescope, multiple different test cases
are run on your code. Passing all of the tests results in a 100% on the autograded
portion of the lab.
You are allowed to submit to Gradescope four times (or less) for this lab. Please ignore the automated email from Gradescope, this information is incorrect.
The maximum grade of your submissions will be your grade for the lab. Note: If
your code doesn’t work (e.g., a syntax error exists, or an error is thrown in
execution), then you will receive an AUTOMATIC ZERO. You should test your
code before submitting to ensure it executes correctly.
Comments
All Python files should include a header with your name,
section, assignment info, references (i.e., who did you collaborate
with on this assignment?; what resource did you use?), and approximate
time taken to do the assignment. Be sure to cite any
allowed external references used to complete the assignment.
Any code without this header will lose 1 point. Here's an
example:
# Tracy Camp
# CSCI 101 – Section B
# Python Lab 6: Timber Regrowth
# References: I used this site to assist with F-string formatting
# http://cis.bentley.edu/sandbox/wp-content/uploads/Documentation-on-f-strings.pdf
# Time: 45 minutes
Submission
Once you are satisfied with your solution to this lab, you need to submit the file to
Gradescope. In Gradescope, go to CSCI 101 > Lab6 and upload Lab6-timber.py.
Note: this lab is worth 5 points (with 2 points of extra credit possible).
To receive full credit, your code must execute in Python 3, and you must
submit a single file (your Python code file). In addition, you must have the input/output match the lab requirements.
Whenever you submit something to Gradescope, we strongly recommend you always double check
what you submitted actually got submitted correctly (e.g., did the file upload correctly?
did you submit the correct file? etc.) If your submission is incorrect, it's on you.
|