-1
How do I show all possibilities according to the number of bit quantization, for example: user: 8 levels bits: 3 need to show then:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
my code so far, and it needs to be without using many ready-made functions, same root mode. please help me:
while True:
nbits = 0
niveis = int(input('Digite os niveis de quantização:'))
q = niveis
v = ""
if niveis < 0:
print("Números negativos não são permitidos")
elif niveis == 0:
nbits = 1
print("O número de bits: ", nbits )
elif niveis == 1:
nbits = 2
print("O número de bits: ", nbits )
elif niveis%2 == 0:
while (niveis>1):
niveis = niveis/2
nbits = (nbits + 1)
print("O número de bits: ", nbits )
print("Possibilidades")
matriz = [[q],[nbits]]
for l in range(1, q):
for c in range(0, nbits):
if l == 1:
v += ("0")
print(v)
Thank you very much friend.
– Marcus Loureiro