# solution of practice exam # here i use math library # but you should have your own functions for ln and e import math # function Fibonacci(n) returns array # of first n terms of Fibonacci sequence # it is necessary for task 3 def Fibonacci(n): F = [0, 1] while len(F) < n: F.append(F[-1] + F[-2]) return F # you should have better function # how many decimals of e do you remember? def e(): return 2.718281828 # here end functions that you should have ready # from previous exercises ##################################################### # task I def taskI(n): P = [-1, 0] while len(P) < n: P.append(P[-1]**2 + 2*P[-1]*P[-2] + P[-2]**2) # now we need to take last iten in P # and get how many character it has # so we convert it to string and call len solution = len(str(P[-1])) print("Solution of task I is", solution) # task II def sinh(x): return (e()**x - e()**(-x)) / 2 def taskII(x): print("Solution of task II is:", round(sinh(math.log(x)), 3)) # task III def taskIII(tol = 10**-9): n = 1 while True: F = Fibonacci(n+1) new = F[-2]/F[-1] # a little trick, if n == 1, # you don't have to have old, becouse # if fails in the n > 1 part. if n > 1 and abs(old - new) < tol: break old = new n += 1 print("Solution of task III is approx.:", new) taskI(20) taskII(1.618) taskIII()