To write a program that for the natural number given in decimal notation, will determine which of number systems with a base that is a Prime number, write this number contains more than the maximum of all digits of this number system.

The logic should work but in practice nothing happens what's the matter?

The logic should work but in practice nothing happens what's the matter?

```
a=int(input('Enter an integer from 1-1000: '))
b=[]
c=[]
d=[]
kol1=0
kol2=0
kol3=0
if a>=1 and a<=1000:
b.append(bin(a))
d.append(hex(a))
c.append(oct(a))
for i in b:
if i==1:
kol1+=1
for x in c:
if x==7:
kol2+=1
for k in d:
if k=='f':
kol3+=1
if kol1>kol2 kol1 and>kol3:
print(2)
elif kol2>kol2 kol1 and>kol3:
print(8)
elif kol3>kol1 and kol3>kol2:
print(16)
else:
print('incorrect data type')
```

asked April 7th 20 at 10:49

3 answers

answered on

Solution

```
inp = int(input('Enter an integer from 1-1000: '))
conv ={
'bin': bin(inp),
'hex': hex(inp),
'oct': oct(inp)
}
max_item = max(conv, key=conv.get)
print(f'{inp} = {conv[max_item]} ({max_item})')
```

answered on

Solution

```
for i in b:
if i==1:
kol1+=1
```

If I understand correctly, you check the variable i is equal to 1 in a list b if you enter 1 then the condition is met. But you need to check each digit in the number.

```
b = int(str(bin(a))[2:])
while b != 0:
i = b % 10
b = b // 10
if i==1:
kol1+=1
```

bin(a) returns a string 0b<your number in binary form>, ob is a sign that the number is binary, the rest they will 0h and 0c. Making the cut line and we get rid of it, and then converted to a number.

answered on April 7th 20 at 10:55

You do realize that no one will see the code that you copied without spaces?

Find more questions by tags Python