🐍 Enter a number and have the program generate e up to that many decimal places. Keep a limit to how far the program will go.
from math import e
def epric(n):
return '%.*f' % (n, e)
if __name__ == '__main__':
correct_input = False
while not correct_input:
print('Precision must be between 1 and 51')
precision = int(input('Number of decimal places: '))
if 51 >= precision > 0:
correct_input = True
print(epric(precision))
from math import e
def epric(n):
return '%.*f' % (n, e)
if __name__ == '__main__':
correct_input = False
while not correct_input:
print('Precision must be between 1 and 51')
precision = int(input('Number of decimal places: '))
if 51 >= precision > 0:
correct_input = True
print(epric(precision))
Comments
Post a Comment