summaryrefslogtreecommitdiff
path: root/python/conversioneBinariaDec.py
blob: cf1087ba4378a2de29f372c9cc2c89dd2fed2338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from math import pow

b = 32
v = []

for i in range(b):
    v.append(0)

str = raw_input('Stringa: ')

if len(str) < b:
    valVuoto = len(str)

i = b - valVuoto
j = 0

while i < b:
    v[i] = int(str[j])
    i += 1
    j += 1

i = b - 1
j = num = 0

while i > -1:
    num += v[i] * pow(2, j)
    i -= 1
    j += 1

print(int(num))