![]() |
program error ? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: program error ? (/thread-25881.html) |
program error ? - Xraydelta - Apr-14-2020 [Please excuse in advance the quality of my English ...I'm French ![]() 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 ![]() 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 ![]() knowing that I did put the indentation in the fifth line... RE: program error ? - stullis - Apr-14-2020 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. |