Python Forum
Basic Programming Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic Programming Help
#1
Hi everyone,

I'm new to the site and just started taking a beginners Python course. I was hoping to see if I could receive some assistance with an assignment I've been working on.

This is the problem I'm working on:

(Financial application: compound value) Suppose you save $100 each month into a savings account with an annual interest rate of 5%. Therefore, the monthly interest rate is After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507 and so on. Write a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month. Here is a sample run of the program:

Enter the monthly saving amount: (WHATEVER NUMBER)

After the sixth month, the account value is (WHATEVER NUMBER)




This is the code I've used so far but I know it's not right. Just confused on how I should word the code so that it will just display the value after the 6th month!It displays the savings after the first month I just don't know how to word it to display the savings amount after 6th months in the savings account.

no1=eval(input("Enter the monthly saving amount:"))

print((no1)*(1+0.00417))
no2=(no1)*((1+0.00417)**6)

print((no1+no2)*(1+0.00417))
no3=(no1+no2)*(1+0.00417)

print=((no1+no3)*(1+0.00417))
no4=(no1+no3)*(1+0.00417)

print=((no1+no4)*(1+0.00417))
no5=(no1+no4)*(1+0.00417)

print=((no1+no5)*(1+0.00417))
no6=(no1+no5)*(1+0.00417)
Reply
#2
Do you mean like this?

** Just remove all the prints (that makes it show each month)


inicial = float(eval(input('Enter the montly saving amount: ')))
x = (1 + 0.00417)


month_one = inicial * x
month_two = (inicial + month_one) * x
month_three = (inicial + month_two) * x
month_four = (inicial + month_three) * x
month_five = (inicial + month_four) * x
month_six = (inicial + month_five) * x

print('The sixth month value is: '+str(month_six))
Reply
#3
I expect that exercise is trying to get you to write a loop:

balance = 801
for month in range(6):
    balance = balance * (1.00417)
print(balance)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
(Sep-11-2018, 04:57 PM)ichabod801 Wrote: I expect that exercise is trying to get you to write a loop:

balance = 801
for month in range(6):
    balance = balance * (1.00417)
print(balance)
As @ichabod801 says, you need a loop. Don't forget to ask the user for the saving amount, and initialise the balance with that amount. Inside the loop, work out and add the interest and then add the saving amount for the next month.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Verilog HDL Programming to Python Programming? noobcoder 1 2,986 Jul-18-2019, 09:28 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020