<jupyter_start><jupyter_text>FIBONACCI SERIES USING DECORATOR¶<jupyter_code>def fibo(f):
    fibonacci = {}
    def helper(x):
        if x not in fibonacci:            
            fibonacci[x] = f(x)
        return fibonacci[x]
    return helper   
@fibo
def fib(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fib(n-1) + fib(n-2)

fib = fibo(fib)
print(fib(8))<jupyter_output>21<jupyter_text>exception handling in files<jupyter_code>file = open("letsupgrade.txt","w")
file.write("Hey Guys I Hope its very good")
file.close()
file = open("letsupgrade.txt","r")
fileData = file.read()
print(fileData)
file.close()
file = open("letsupgrade.txt","r")
file.write("Hey")
file.close()
try:
    file= open('letsupgrade.txt', 'w')
    file.write("hey")
    print(file.read())
    file.close()
except IOError:
    print("not writable")<jupyter_output>not writable
StarcoderdataJupyterStructuredCleanDedup