Warning

# Computer Lab 03, Functions

## puzzle

• a weekly puzzle to train the brain

## practical work

We use the code implemented last week, from Wentworth2012 and make it more flexible by encapsulating the core functionality in functions.

2.14.5 Create a function compute_final_amount that will have P,r,n,t as the input parameters. Comment the function appropriately. Make the code robust against dividing by zero runtime problem. Test the functionality.

time difference variant of 2.14.7 and 2.14.8. Implement a function compute_time_diff(h1,m1,h2,m2) that returns two values - hours, minutes - time difference between t2-t1, where the time is expressed in hours and minutes. Expect 24 hours notation.

Usage:

>>> h,m = compute_time_diff(13,20,15,10)
>>> print(h,m)
1 50

## homework

• Solve homework right_triangle and submit it via Upload system in time! Check the deadline in Upload system.
• Read chapters 6,7,8,9 from Wentworth2012. This material is for the next two lectures/labs.
courses/be5b33prg/labs/week_03.txt · Last modified: 2018/10/15 08:57 by iscenahm 