4QQMN506 Programming for Accounting and Finance Assignment

Post New Homework

4QQMN506 Programming for Accounting and Finance - Kings Business School

Part A (Theory)

Question 1:

a) Explain the difference between a function and a method.

b) Explain inheritance, polymorphism and data encapsulation. Does Python syntax enforce data encapsulation?

c) How is the lifetime of an object determined? What happens to an object when it dies?

d) Explain what happens when a program receives a non-numeric string when a number is expected as input, and explain how the try-except statement can be of use in this situation. Why would you use a try-except statement in a program?

e) Explain what happens when the following recursive function is called with the values "hello" and 0 as arguments:

Question 2:

The two fundamentals of computer science are Algorithms and Information Processing.

a) Briefly describe what is meant by these two concepts?

b) What are the four defining features of an algorithm?

Question 3:

a) Elaborate and explain try-except statements. Why would you use this in a program?

b) Elaborate and explain Multi-Way if statements. Use flowcharts and examples.

Question 4:

Tom is a junior quantitative analyst at a large London based hedge fund. He has been assigned a task to develop a program to continually process and store incoming real time stock price data (for many stocks based in Europe and USA exchanges) from a platform and store this into a database as efficiently as possible.

Discuss the costs and benefits for different programming approaches and object orientated programming (OOP) Tom could utilise in designing this complex program.

Part B (Practical Coding)

Question 5:

The German mathematician Gottfried Leibniz developed the following method to approximate the value of π:

π/4 = 1 - 1/3 + 1/5 - 1/7 + . . .

Write a program that allows the user to specify the number of iterations used in this approximation and that displays the resulting value.

An example of the program input and output is shown below:

Question 6:

A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor.

Define a function isSorted that expects a list as an argument and returns True if the list is sorted, or returns False otherwise.

(Hint: For a list of length 2 or greater, loop through the list and compare pairs of items, from left to right, and return False if the first item in a pair is greater.)

Below is an example of the main function:

Below is an example of the associated output:

Question 7:

In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1.

Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on.

A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people's eyes glaze over at the first mention of mathematics, your challenge is to write a program that demonstrates the futility of playing the game.

Your program should take as input the amount of money that the player wants to put into the pot, and using a random number generator play the game until the pot is empty.

At that point, the program should print:

1. The number of rolls it took to break the player

2. The maximum amount of money in the pot.

Attachment:- Programming for Accounting and Finance.rar

Post New Homework
Captcha

Looking tutor’s service for getting help in UK studies or college assignments? Order Now