mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
Merge pull request #32 from akshaysharma096/master
PEP style and fixed exception on input other and integer type
This commit is contained in:
commit
6a68559e4d
|
@ -1,10 +1,13 @@
|
||||||
"""
|
"""
|
||||||
This is a pure Python implementation of Dynamic Programming solution to the fibonacci sequence problem.
|
This is a pure Python implementation of Dynamic Programming solution to the fibonacci sequence problem.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Fibonacci:
|
class Fibonacci:
|
||||||
|
|
||||||
def __init__(self, N=None):
|
def __init__(self, N=None):
|
||||||
if N:
|
if N:
|
||||||
|
N = int(N)
|
||||||
self.fib_array = [0] * (N + 1)
|
self.fib_array = [0] * (N + 1)
|
||||||
self.fib_array[0] = 0
|
self.fib_array[0] = 0
|
||||||
self.fib_array[1] = 1
|
self.fib_array[1] = 1
|
||||||
|
@ -43,6 +46,7 @@ if __name__ == '__main__':
|
||||||
"\n********* Enter different values to get the corresponding fibonacci sequence, enter any negative number to exit. ************\n")
|
"\n********* Enter different values to get the corresponding fibonacci sequence, enter any negative number to exit. ************\n")
|
||||||
while True:
|
while True:
|
||||||
print("Enter value: ", end=" ")
|
print("Enter value: ", end=" ")
|
||||||
|
try:
|
||||||
i = eval(input())
|
i = eval(input())
|
||||||
if i < 0:
|
if i < 0:
|
||||||
print("\n********* Good Bye!! ************\n")
|
print("\n********* Good Bye!! ************\n")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user