Commit 1e791784 authored by wongkai junttajit's avatar wongkai junttajit

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

parent 2f82f024
......@@ -6,11 +6,11 @@ def value1(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=[1, 1,1,1,1, 0,0,0,0]
print(value1(v,4,4))
v=[0,0,0,0,1,0,1,1]
print(value1(v,4,3))
#2.คะแนนพิเศษ
def value2(v, pos, neg):
ang= list(map(int,v))
......@@ -19,6 +19,6 @@ def value2(v, pos, neg):
print(value2('100010000', 4, 4))
print(value2('000100100', 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