diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/conversioneBinariaDec.py | 12 | ||||
-rw-r--r-- | python/lswf.py | 1 | ||||
-rw-r--r-- | python/parentesi.py | 14 | ||||
-rw-r--r-- | python/scommesse.py | 4 |
4 files changed, 15 insertions, 16 deletions
diff --git a/python/conversioneBinariaDec.py b/python/conversioneBinariaDec.py index 2ff1bb6..113eb85 100644 --- a/python/conversioneBinariaDec.py +++ b/python/conversioneBinariaDec.py @@ -1,18 +1,18 @@ -from math import pow +import math b = 32 v = [0 for i in range(b)] -str = input('Stringa: ') +stringa = input('Stringa: ') -if len(str) < b: - valVuoto = len(str) +if len(stringa) < b: + valVuoto = len(stringa) i = b - valVuoto j = 0 while i < b: - v[i] = int(str[j]) + v[i] = int(stringa[j]) i += 1 j += 1 @@ -20,7 +20,7 @@ i = b - 1 j = num = 0 while i > -1: - num += v[i] * pow(2, j) + num += v[i] * math.pow(2, j) i -= 1 j += 1 diff --git a/python/lswf.py b/python/lswf.py index 7a309ad..c955631 100644 --- a/python/lswf.py +++ b/python/lswf.py @@ -8,7 +8,6 @@ def fibonacci(N): if fib[i] > N: break - return i diff --git a/python/parentesi.py b/python/parentesi.py index a89e046..e4967a9 100644 --- a/python/parentesi.py +++ b/python/parentesi.py @@ -12,21 +12,21 @@ t = q = g = 0 tot = 0 -for i in range(len(stringa)): - if stringa[i] == '(': +for i in stringa: + if i == '(': t += 1 - elif stringa[i] == '[': + elif i == '[': q += 1 - elif stringa[i] == '{': + elif i == '{': g += 1 - if stringa[i] == ')' and t > 0: + if i == ')' and t > 0: t -= 1 tot += 1 - elif stringa[i] == ']' and q > 0: + elif i == ']' and q > 0: q -= 1 tot += 1 - elif stringa[i] == '}' and g > 0: + elif i == '}' and g > 0: g -= 1 tot += 1 diff --git a/python/scommesse.py b/python/scommesse.py index b947df1..f65c04f 100644 --- a/python/scommesse.py +++ b/python/scommesse.py @@ -4,8 +4,8 @@ carteOut = [] def cOutPresente(x): s = False - for i in range(len(carteOut)): - if (carteOut[i] == x): + for i in carteOut: + if i == x: s = True if not s: |