Fundamentals of Numeric Computing
CPAN 112 | Assignment 3
Simple Interest lab
Program & Assignment
Write a program to calculate simple interest given Principal, Rate, Years, Months
Part – A
Define a function to get the total time in years
- Ask the user to enter the value for year, months and days using the input()
- Define a function using a key word “def” name it get_time (year, months, days)
Add the codes - Return total time in years
Your output should look like :
Enter year:2 Enter months:6 Enter the days:73 Total time in years is 2.7 years |
Part B
Find the simple interest and must use the function created in the part I
- Get the value of principal and rate from the user
- Define a method with the key word ‘def’ and name it Simple_interest ()
Add codes to find simple interest - Call the methods to print the simple interest by calling the function from the part A
You final output should like
Enter year:2 Enter months:6 Enter the days:73 principal:1000 rate(in %) :5 Total time in years is 2.7 years Total interest earned is $ 135.0 |
Solutions:
Note: Format it yourself.
- PART A:
- PART B: