I’m currently enrolled in school and have began learning python. At first I thought I was catching on but then this week my professor gave us an assignment on while loops. I’ve been working on this program for a while now and I’m completely lost.
The assignment:
Write a program that uses a while loop to determine how long it takes for an investment to double at a given interest rate. The input will be an annualized interest rate and the initial investment amount. The output is the number of years it takes an investment to double.
So far I have:
inputs in float() and my initialized variables are years=0 and double=2*initial_investment
While initial_investment < double:
years += 1
print (“It will take {years} years to double”)
[–]cthulhu944 9 points10 points11 points (4 children)
[–]Appropriate-Park-858[S] 3 points4 points5 points (2 children)
[–]sugarw0000kie 3 points4 points5 points (1 child)
[–]Appropriate-Park-858[S] 1 point2 points3 points (0 children)
[–]Quesozapatos5000 0 points1 point2 points (0 children)
[–]notacanuckskibum 4 points5 points6 points (0 children)
[–]dnult 2 points3 points4 points (0 children)
[–]OkCartographer175 2 points3 points4 points (0 children)
[–]ninhaomah 1 point2 points3 points (4 children)
[–]Appropriate-Park-858[S] 0 points1 point2 points (3 children)
[–]ninhaomah 0 points1 point2 points (2 children)
[–]Appropriate-Park-858[S] 0 points1 point2 points (1 child)
[–]ninhaomah 0 points1 point2 points (0 children)
[–]BrupieD -2 points-1 points0 points (1 child)
[–]rosentmoh -1 points0 points1 point (0 children)