-->
当前位置:首页 > 题库

PROGRAMMING:Number of bit 1

Luz5年前 (2021-05-10)题库411
Enter a non negative integer and find the number of 1 after it becomes binary (hint: use bin function).
###Input format:
Enter a positive integer.
###Output format:
The number of output 1.
###Input sample 1:
Here is a set of inputs. For example:
```in
thirty-seven
```
###Output sample 1:
The corresponding output is given here. For example:
```out
three
```
###Input sample 2:
Here is a set of inputs. For example:
```in
0
```
###Output sample 2:
The corresponding output is given here. For example:
```out
0
```







answer:If there is no answer, please comment
```
n=int(input())
s=bin(n)
lst=[int(i) for i in s[2:]]
print(sum(lst))
```