School of Computer Science and Software Engineering

# School of Computer Science and Software Engineering

## CITS4406 Problem Solving and Programming

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.

#### Practical Details:

• The test will run for 1 hour from 11am until 12pm in CSSE Lab 2.01
• It will be a programming test. You will be required to write a python module for each question. You will have access to the python language reference and the Idle environment, but no other resources.
• There will be 4 questions, each worth equal marks. See below for examples.
• At the end of the test, your 4 python modules should be submitted via cssubmit

#### Sample Questions:

The following questions a similar to questions that you can expect in the midsemester test.
1. Define a function `consonants(str)` that takes a string and returns the same string with all vowels removed.
``` >> consonants("Tim A French") 'Tm Frnch' ```
5 marks
2. 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`
Write a module that asks the user for the number of rabbits, the number of foxes, and the number of generations, and prints out how the populations change (you do not have to worry about negative numbers, or integer values). ``` >> 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 ```
5 marks
3. Write a module that prints out the 6 main steps of the software development process, one to a line.
``` No sample given ```
5 marks
4. Write a module `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 ```
5 marks

5. #### Resources:

A similar unit CITS1401 has previously used a multiple choice exam for the mid-semester test. While this format is very different from your test, it may provide some useful revision.

No earlier papers are available because the unit was new in 2012.

# The University of Western Australia

## University information

CRICOS Code: 00126G

## This Page

Last updated:
Thu Dec 8 14:28:59 2011

Website Feedback:
lyndon.while@uwa.edu.au

http://undergraduate.csse.uwa.edu.au/units/CITS4406/