Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 how do i rewrite this code to give me 10 outputs
#1
# File: Futurevalue.py
# A simple program illustrating the future value of a savings account in 10 years
def main():
    p = eval(input ("Enter the initial principal amount in the savings account: "))
    apr = eval(input ("Enter the annual interest rate: " ))
    for i in range(10):
        p = p*(1 + apr)
                                 
    print("The value in 10 years is:", p)
    


main()
Quote
#2
your print statement is outside the loop.
Add 4 spaces before the print, thus making it part of the loop and you will see 10 outputs
Quote
#3
(Mar-29-2018, 04:24 AM)Larz60+ Wrote: your print statement is outside the loop.
Add 4 spaces before the print, thus making it part of the loop and you will see 10 outputs

That works. Thank you
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Outputs missing SamAnw 4 233 Feb-12-2020, 04:32 PM
Last Post: adetheheat
  Cleaner way to rewrite fakka 5 359 Dec-05-2019, 04:53 AM
Last Post: stullis
  How do I rewrite this .bat file code onto Python? SteampunkMaverick12 4 365 Nov-02-2019, 11:28 PM
Last Post: snippsat
  Interpreter and running a .py file give different outputs PythonNPC 5 521 Jul-21-2019, 01:07 PM
Last Post: PythonNPC
  Rewrite a function to make it work with 'bottle-pymysql' nikos 1 423 Feb-26-2019, 02:59 PM
Last Post: nikos
  My code is taking longer time to give result rajeshwin 4 629 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  piexif rewrite exif data yawstick 2 952 Oct-09-2018, 08:56 PM
Last Post: yawstick
  Not having to rewrite 'obj.' on each line beuaaa 4 857 Sep-30-2018, 02:21 AM
Last Post: micseydel
  Save outputs to Desktop cisicomania 1 733 Aug-31-2018, 10:08 AM
Last Post: Gribouillis
  Help Editing/Problem with outputs stanthaman42 7 1,260 Jul-11-2018, 05:30 PM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 1 Guest(s)