Commit f34ae4d6 authored by wongkai junttajit's avatar wongkai junttajit

ส่งการบ้าน assignment และคะแนนพิเศษ ggwp

parent f1601286
def value(v,pos=4,neg=3):
def value(v,pos,neg):
sign = -1 if v[0] == 1 else 1
return sign * sum([v[i] * 2 ** (pos - i) for i in range(1, pos+neg+1)])
v=[0,0,0,0,1,0,1,1]
print(value(v,4,3))
print(value([],4,3))
......@@ -15,6 +15,6 @@ def values(v, pos=5, neg=3):
print(values('000010100', 5, 3))
print(values('', 5, 3))
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