The mid-semester test will be held in the lecture in Week 6. The test is worth 15% of the total mark for the unit, and it examines all of the material discussed in the lectures and lab classes up to the week of the test.
Post requests for clarification about any aspect of the test to help4406.
consonants(str)
that takes a string and returns the same string with all vowels removed.
>> consonants("Tim A French")
'Tm Frnch'
The Lotka-Volterra predator prey equations describe how populations of predators (say foxes) and prey (say rabbits) change over generations. When there are not many prey, and many predators, the prey are more likely to be caught, but the predators are more likely to starve. When there are many prey, and not many predators, the predators are likely to thrive, while the prey are less likely to be caught, but more likely to starve. The prey are constantly breeding (like rabbits).
You are to write a program that predicts the population of rabbits and foxes at each generation.
Given r_t
rabbits at generation t
and f_t
rabbits and generation t
then the populations at generation t+1
are given by the equations:
r_t+1 = r_t + 0.03 * r_t - 0.001 * f_t * r_t
f_t+1 = f_t - 0.01 * f_t + 0.001 * f_t * r_t
>> main()
How many rabbits? 30
How many foxes? 10
How many generations 5
Rabbit fox
30.60 9.31
31.23 8.67
31.90 8.08
32.60 7.53
33.33 7.03
No sample given
imperial2metric
that requests an imperial measurement (in feet or ounces) and returns the equivalent metric measurement (in meters or grams, respectively). 1 foot is 0.3048 meters and 1 ounce is 28.3495 grams.
>>> imperial2metric()
Enter a measurement in feet, or ounces 12 feet
3.6576000000000004 meters
>>> imperial2metric()
Enter a measurement in feet, or ounces 10 ounces
283.495 grams
No earlier papers are available because the unit was new in 2012.