# Using a while loop which stops due to meeting a tolerance condition, design a function to find the following sum. #β #n=0 #β #e #nx #, x<0 import math # can change this tolerance to any number tolerance = 0.001 x = -1 difference = 20 sum = 0 n = 0 # while while n < 5: sum += math.exp(n*x) n += 1 print(sum())
Run
Reset
Share
Import
Link
Embed
Language▼
English
δΈζ
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question