CS551N Assessment 1 2023-2024
General Information
Total mark: 30.
Type: a programming exercise.
Description: an individual assessment consisting of several programming tasks.
There should be one python script per task. Each script file should be named the same as the requested program name, e.g. incomeTaxCalculator.py and trapeziumAreaCalculator.py. You should not import any Python libraries to your solution for this assessment unless explicitly stated in the exercise instructions. For each task, a 50% penalty will be applied if you use unpermitted python libraries. For example, if you score 10 marks in a task and a penalty is applicable, you will actually get only 5 marks after the penalty.
A grading rubric is attached at the end of this assessment.
Learning Outcomes:
• An ability to write and run programs.
• An ability to judge how computer programs should be structured.
• An understanding of, and ability to apply, techniques to support correct code in a program.
• The ability to analyse simple problems, and design a program solution.
• The ability to apply programming concepts for solving problems in order to create a new program.
• Knowledge and understanding of basic programming concepts and their application: scope, functions, recursion, modular programming, importing and invoking code from within other code.
1. You pay Scottish Income Tax if you live in Scotland. It’s paid to the Scottish Government. Taking the taxable income, calculate the income after tax. Then, check the range that the tax rate falls into. (18 Marks)
Your program should:
1.1 Ask the user to input their taxable income.
1.2 Call a function (that you created) that received the taxable income and calculates the income after tax and tax rate.
1.3 Print the income after tax and rounded to 1 decimal place.
1.4 Print a message describing the tax rate falls under.
Information for you:
• Your program should calculate the income tax in Scotland using the following table:
Please note that input of taxable income must be integer.
• Your program should display the following messages informing the user income before tax, income after tax and what tax rate that falls under:
For example, if the user input taxable income, the output would be:
>>> Your tax rate is xxx.
Your income before taxis xxx.
Your income after tax is xxx.
2. A trapezium is a 4-sided 2-dimensional shape with straight lines with a pair of opposite sides parallel. The parallel sides are referred to as bases and the other two sides are referred to as legs. The distance at right angles from one base to the other is called the altitude. (12 marks):
Write a program that calculates the area of a trapezium.
2.1 Ask the user to input the first base length, the second base length, and the height.
2.2 Call a function (you created in this program) that receives the correct number of parameters to calculate the area of a trapezium and return this value.
2.3 Print the calculated area of trapezium.
The formula to calculate the area of a trapezium is:
Computer Programming Grading Rubric