Objectives

The objectives of this assignment are:

To demonstrate the ability to implement algorithms using basic data structures and operations on them.

To gain experience in designing an algorithm for a given problem description and implementing that

algorithm in Python.

Submission Procedure

1. Put you name and student ID on each page of your solution.

2. Save your les into a zip le called yourFirstName yourLastName.zip

3. Submit your zip le containing your solution to Moodle.

4. Your assignment will not be accepted unless it is a readable zip le.

Important Note:

Please ensure that you have read and understood the university’s policies on plagiarism

and collusion available at http://www.monash.edu.au/students/policies/academic-integrity.html. You

will be required to agree to these policies when you submit your assignment.

Marks:

This assignment has a total of 25 marks and contributes to 5% of your nal mark. Late submission

will have 5% o the total assignment marks per day (including weekends) deducted from your assignment mark.

(In the case of Assignment 1, this means that a late assignment will lose 1.25 marks for each day (including

weekends)). Assignments submitted 7 days after the due date will normally not be accepted.

Marking Guide:

Task 1: 10 marks

(a) Code readability (Non-trivial comments where necessary and meaningful variable names) – 2 marks

(b) Correct input handling – 2 marks

(c) Correct result – 2 marks

(d) Loop calculates each term correctly – 4 marks

Task 2: 15 marks

(a) Code readability (Non-trivial comments where necessary and meaningful variable names) – 4 marks

(b) Correct input handling – 4 marks

(c) Checking magic square property – 2 marks

(d) Loop allowing for user input – 2 marks

(e) Checking cell contains 0 – 1 mark

(f) Undoing if value not valid – 2 marks

Task 1: Continued Fractions 10 Marks

Write a Python program that takes as input non-negative integer n and then computes an approximation for

the value of e using the rst n + 1 terms of the continued fraction:

e ≈ 2 +

1

1 +

1

2+

2

3+ 3

…

For example:

If you entered 2, your program would output 2.7272727272727275 as:

e ≈ 2 +

1

1 +

1

2+ 2

3

and if you entered 3, your program would output 2.7169811320754715 as:

e ≈ 2 +

1

1 +

1

2+

2

3+ 3

4

.

Task 2: Magic Squares 15 Marks

Information:

A magic square is a table with n rows and n columns, such that the numbers in each row, and in each column,

and the numbers in the main diagonals, all add up to the same number which we will refer to as the magic sum.

All entries are distinct. A partial magic square is a magic square that has some entries missing. For example,