Commit 96947f20 authored by Phuengton Chummuel's avatar Phuengton Chummuel

add quiz

parent 508818ac
# 5
import numpy as np
e = np.e
def double(V):
sign = 1 if V[0] == '0' else -1
tmp = [ int(V[i]) * 2 ** (11-i) for i in range(1, len(V)) ]
e = sum(tmp[0:11])
f = 1+sum(tmp[11:])
return sign * 2 ** (e - 1023) * f
print(double('0011111111110000000000000000000000000000000000000000000000000000'))
print(double('1100000000000000000000000000000000000000000000000000000000000000'))
print(double('0100000000110111000000000000000000000000000000000000000000000000'))
# 2
import numpy as np
e = np.e
def f(x):
return e**(-x)
def third(f,x, h):
return (f(x+2*h) - 2*f(x+h) + 2*f(x-h)-f(x-2*h))/(2*h**3)
print(third(f, 1, 0.001))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment