. |
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
xxxxxxxxxx
t = input()
s = 0
n = len(t)
for i in range(0,n):
s = s + int(t[i])*pow(2,n-i-1)
print s
xxxxxxxxxx
x = input()
x = int(x)
result = ""
if x < 2:
result = str(x)
else:
quotient = x
while quotient != 0:
reste = quotient % 2
result=''.join([str(reste), result])
quotient = quotient/2
print(result)
1 | |||||||
1 | 0 | 1 | 1 | 0 | 1 | ||
+ | 1 | 0 | 0 | 0 | 1 | ||
1 | 1 | 1 | 1 | 1 | 0 |
Porte logique | Schéma | Écritures | Table de vérité | ||||||||||||||||||
ET |
0,0 A B C A B |
|
|
||||||||||||||||||
OU |
0,0 A B C D E F A B |
|
|
||||||||||||||||||
NON |
0,0 A |
|
|
||||||||||||||||||
OU exclusif |
0,0 A B C D E F G H I A B |
|
|
A | B | ¬A | (¬A)∨B |
0 | 0 | 1 | 1 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 1 | 0 | 1 |
Entrées | Sorties | ||
A | B | Retenue R | Somme S |
0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 |
1 | 0 | 0 | 1 |
1 | 1 | 1 | 0 |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
+ | 1 |
+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |
1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |
1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
+ | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 |
+ | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
+ | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
xxxxxxxxxx
import math
x = input()
x = float(x)
def entB(n):
result = ""
if n < 2:
result = str(n)
else:
quotient = n
while quotient != 0:
reste = quotient % 2
result=''.join([str(reste), result])
quotient = quotient/2