输入一个整数(int类型)

这个数转换成2进制后,输出1的个数

  • 使用bin函数将输入的整数转换成二进制,通过count('1')来统计1出现的次数。
a=int(input())
b=bin(a)
print(b.count('1'))