Oct-04-2018, 03:49 PM
For year 5 I need it to format to the 12th decimal place. I have tried reading the documentation, but it isn't working.
I need str(yearFiveTest) to express to 12 decimals. I have tried %.12f like the documentation states. I have tried .format(.12f)
Can anyone help please?
Here is my code:
price = 8000
myLoop = True
while myLoop == True:
yearOne = price * .03
totalOnePrice = yearOne + price
print(end='In 1 year, the tuition will be $' + str(totalOnePrice) + '.\n')
yearTwo = totalOnePrice * .03
yearTwoTest = yearTwo + totalOnePrice
print(end='In 2 years, the tuition will be $' + str(yearTwoTest) + '.\n')
yearThree = yearTwoTest * .03
yearThreeTest = yearThree + yearTwoTest
print(end='In 3 years, the tuition will be $' + str(yearThreeTest) + '.\n')
yearFour = yearThreeTest * .03
yearFourTest = yearFour + yearThreeTest
print(end='In 4 years, the tuition will be $' + str(yearFourTest) + '.\n')
yearFive = yearFourTest * .03
yearFiveTest = yearFive + yearFourTest
print(end='In 5 years, the tuition will be $' + str(yearFiveTest) + '.\n')
myLoop = False
I need str(yearFiveTest) to express to 12 decimals. I have tried %.12f like the documentation states. I have tried .format(.12f)
Can anyone help please?
Here is my code:
price = 8000
myLoop = True
while myLoop == True:
yearOne = price * .03
totalOnePrice = yearOne + price
print(end='In 1 year, the tuition will be $' + str(totalOnePrice) + '.\n')
yearTwo = totalOnePrice * .03
yearTwoTest = yearTwo + totalOnePrice
print(end='In 2 years, the tuition will be $' + str(yearTwoTest) + '.\n')
yearThree = yearTwoTest * .03
yearThreeTest = yearThree + yearTwoTest
print(end='In 3 years, the tuition will be $' + str(yearThreeTest) + '.\n')
yearFour = yearThreeTest * .03
yearFourTest = yearFour + yearThreeTest
print(end='In 4 years, the tuition will be $' + str(yearFourTest) + '.\n')
yearFive = yearFourTest * .03
yearFiveTest = yearFive + yearFourTest
print(end='In 5 years, the tuition will be $' + str(yearFiveTest) + '.\n')
myLoop = False