CS计算机代考程序代写 python Workshop

Workshop

SMM283-INTRODUCTION TO PYTHON Dr. Adrian Euler

1 | P a g e

HOME WORK 1

[FORMATIVE]

TASK SET 1

(a)

(i) Run the “Hello World!” program on your system. Experiment with leaving out parts of the

program, to see what error messages you get. Experiment to find out what happens when more

arguments are added in the function print().

(ii) Write a Python program that prints out the phrase “hello, world:” several times following the

effect of a variety of specifications in printing “hello, world” (15 characters) .

The output should be as follows:

:hello, world:

:hello, world :

:hello, wor:

:hello, world :

:hello, world :

:hello, world :

: hello, wor:

:hello, wor :

(iii) Write a program that prints a previously initialized floating-point variable representing a

bond’s yield with in ways following various output formatting specifications (10 characters

wide). The output should be as follows:

:Bond yield: 0.045__:

: Bond yield: 0.045:

: Bond yield: 0.04 :

:Bond yield: 4.5%_ _:

:Bond yield: 4.50%_ :

(b)

Write a Python program that computes the future value of $100.00 received today and values it a

year from now. Assume an annual compound interest rate of 0.0245. The computed value should

be output right adjusted, with two decimal places, and with the £ symbol appended.

TASK SET 2

(a)

SMM283-INTRODUCTION TO PYTHON Dr. Adrian Euler

2 | P a g e

(i) Write a Python program that prompts the user for a monetary amount to be received at time t

(you may input this interactively or initialize statically), the discounting rate and computes the

discounted value.

(ii) Rewrite the solution of (i) so that the frequency of compounded is included and specified

through an input prompt. Use the formula

where n is the frequency of compounded i.e. n=2 for semi-annual compounding, n=12 for

monthly compounding, etc.

(b)

Write a program that computes the price of a single equity share, assuming that the stock has just

paid a dividend of £0.60, and future dividend payouts are expected to be precisely at this level

forever. The required rate of return of this stock is 10 per cent. Use the perpetuity formula.

r

D
P0 =

TASK SET 3

(a)

Recreate all Python scripts from lecture 1. Discuss the main features of the interactive shell and

flag out any issues you may have faced in the process and with code.

(b)

Refer to end of chapter 2 exercises in Schneider (2015) and code the following: exercise set

2.12. questions 31, 32, 64, 65; exercise set 2.2 , questions 93, 104, 107; exercise set 2.3, questions

54, 55, 56, 57, 58

nr

n

r
1

FV
PV





+

=