Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 5 - Loops - Programming Exercises - Page 163: 5.28

Answer

code

Work Step by Step

# 5.28 (Compute e) You can approximate e by using the following series: # Write a program that displays the e value for i = 10000, 20000, . . ., and # 100000. (Hint: Since , then is # Initialize e and item to be 1 and keep adding a new item to e. The new item is # the previous item divided by i for i = 2, 3, 4, . . . .) e = 1 item = 1 for i in range(1, 100000 + 1): item = item / i e += item if i == 10000 or i == 20000 or i == 30000 or i == 40000 or \ i == 50000 or i == 60000 or i == 70000 or i == 80000 or \ i == 90000 or i == 100000: print("The e is " + str(e) + " for i = " + str(i))
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.