- To check number is in binary or not
User Input: 11111
Output: Number is in binary form
def binary(num) :
while(num!=0):
if(num%10==0 or num%10==1):
num=int(num/10)
else : return 0
return 1
num=int(input("Enter Your Number :"))
if binary(num):
print("Number is in binary form")
else :
print("Number is not in binary form")
Enter Your number : 1101 Number is in binary formProgram
Binary Numbers : Numbers with only 0 & 1 combination
Examples like: 101, 111, 10, 11111
Main Logic :
def binary(num) :
while(num!=0):
if(num%10==0 or num%10==1):
num=int(num/10)
else : return 0
return 1
Divide the number by 10 while your number becomes 0[ZERO] &
In-between check, is there any remainder other than 0 & 1
Coming Soon !
QuickStrength does not come from winning. Your struggles develop your strengths.