+ 1
[Solved]. Re: Multiples of 3 & 5 in python
[Solved] Why does this code return the numbers with the period? import numpy as np numbers = np.array([]) for i in range(1,100): if i % 3 == 0 and i % 5 == 0: numbers = np.append(numbers, i) print(numbers) Returns: [15. 30. 45. 60. 75. 90.] and not [15 30 45 60 75 90] like this code does: x = np.arange(1,100) print(x[(x%3==0)&(x%5==0)])
4 Antworten
+ 1
Numpy formats floating point numbers like that. 100. actually means 100.00
try
print(numbers.astype(int))
https://code.sololearn.com/cRhhBdEElSkH/?ref=app
0
>Numpy formats numbers like that. 100. actually means 100.00
But why does not the second (solution) code return it like that?
0
I edited the answer. Please read again
0
Fantastic! Thanks a lot! :-)