Commit f4270624 authored by tanakrit's avatar tanakrit Committed by Patiphan Marak

ส่งการบ้าน assingment ครับ

parents d4b870df d0d36d07
......@@ -93,10 +93,7 @@
},
"outputs": [],
"source": [
"# มีหลายตัวเลขที่ไม่\n",
"x = 1.0\n",
"y = x / 3.0\n",
"#print(\"Equal\" if x == y*3.0 else \"Not Equal\")"
""
]
},
{
......
#pos = input("pos :")
#neg = input("neg :")
def value(v,p,n):
sign = -1 if v[0] == 1 else 1
return sign * sum([v[i]*2**(p - i)for i in range(1,p+n+1)])
v = [0,0,1,1,1,1,0,1]
print(value(v,4,3))
def values01(v,p,n):
bos = list(map(int,v))
sign = -1 if bos[0] == 1 else 1
return sign * sum([bos[i] * 2 ** (p - i) for i in range(1, p + n + 1)])
print(values01('00101101', 4, 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