Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
program error ?
#1
[Please excuse in advance the quality of my English ...I'm French Tongue ]

Hello,
I'm new on this forum and begin in python programming;
I recently had an exercise that involved completing a program to determine the value of "t" to the nearest 0.1 at which point "C" was less than 0.2 with C = 20*exp(-0,1*t).
So I created the following program and don't really understand why it doesn't work Think :

from math import*
t = 0
C = 20*exp(-0.1*t)
while C >= 0.2 :
t += 0.1
print(t)

If you could help me then Idea
knowing that I did put the indentation in the fifth line...
Reply
#2
C needs to be calculated within the loop. Otherwise, C stays the same even though t changes because C is not recalculated.

Also, for the future, use the python tags (click on the Python button on the toolbar) so the code is displayed better.
Reply


Forum Jump:

User Panel Messages

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