题解 | #求int型正整数在内存中存储时1的个数#
求int型正整数在内存中存储时1的个数
https://www.nowcoder.com/practice/440f16e490a0404786865e99c6ad91c9
a = int(input("")) count = 0 while a/2 != 0: if a%2 == 1: count+=1 a = int(a/2) print(count)
利用理论知识:除二取余法 加深python中数据类型的概念 5/2 = 2.5 与int的用法