hdarwin

cstutoringcenter.com_Binary Numbers

Jan 4th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.14 KB | None | 0 0
  1. sum = 0
  2. for f in file("decimals.txt", "r"):
  3.     for x in str(bin(int(f.replace('\n', ''))))[2:]:
  4.         if x == '1':sum += 1
  5. print sum
Advertisement
Add Comment
Please, Sign In to add comment