+ 1

How do I get rid of a .0 at the end of a number

Every time I'm doingnumber code it ends up having a .0 at the end

25th May 2022, 6:22 AM
Orber playz
5 ответов
+ 4
Orber playz in Python, whenever you divide by using the / operator, the result is always a floating point data type. Consequently, the rest of the expression becomes floating point, too. You can get an integer result if: 👉 both operands of the division are integer AND 👉 you replace / with the // operator which is the floor division operator. 💡Another way is to pass the result into the int() function.
25th May 2022, 7:28 AM
Brian
Brian - avatar
+ 4
As Brian said print(int(2 * 4 - 8 / 2 - 4))
25th May 2022, 9:27 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Orber playz , -> it would be helpful if you tell us what programming language you are using. -> please also post a link to your code.
25th May 2022, 6:30 AM
Lothar
Lothar - avatar
+ 2
Python code
25th May 2022, 6:59 AM
Orber playz
25th May 2022, 7:01 AM
Orber playz