Advertisement
elena1234

binary number string to int in Python

Apr 13th, 2022
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. ''' Question 11
  2. Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence.
  3. Example:
  4. 0100,0011,1010,1001
  5. Then the output should be:
  6. 1010 '''
  7.  
  8. inputStr = input().split(",")
  9. for var in inputStr:
  10.     variable_int = int(var, 2)
  11.     if variable_int % 5 == 0:
  12.         print(var)
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement