Answer to Question #318661 in Python for ritu

Question #318661

Create a module series.py containing functions to determine Fibonacci series and Exponential series. Import the module created to make it accessible, and Call the functions of that module with module name . Demonstrate the access of functions in the module created. 


1
Expert's answer
2022-03-27T03:05:18-0400
# series.py


def Fibonacci(n):
    if n == 0:
        return 0


    f0 = 0
    f = 1
    for i in range(1, n):
        f, f0 = f+f0, f
    return f


def Exponential(n, x=1):
    s = 1
    a = 1
    for i in range(1,n+1):
        a *= x/i
        s += a
    return s


import series


def main():
    n = int(input("Enter a positive integer: "))
    if n < 0:
        print('Not positive number!')
        exit()
    f = series.Fibonacci(n)
    print(f'{n}-th Fibonacci number is {f}')


    x = float(input('Enter a number: '))
    y = series.Exponential(n, x)
    print(f'Exponetial({n}, {x}) = {y}')


if __name__ == '__main__':
    main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS