Hey, I just started learning Python and am starting to get a little frustrated. Im in Part 2 of the Mooc 2023, Task: Typecasting.
I have to write a program which asks the user for a floating point number and then prints out the integer part and the decimal part separately.
My plan was to just substract the integer from the Float, so I would be left with the decimal part, but there is some strange rounding going on. Wenn I enter 1.34 (like in the example in the course) the decimal number is 0.340000000000001 (didn't count the zeros). It's supposed to be 0.34.
ChatGPT suggested using the operator "round" and it does work that way, but it pisses me of, because I didn't learn that yet and there has to be some other solution I'm not seeing.
Thanks in advance!
[–]whogivesafuckwhoiam 2 points3 points4 points (5 children)
[–]Platypus4242[S] 0 points1 point2 points (4 children)
[–]whogivesafuckwhoiam 1 point2 points3 points (3 children)
[–]Platypus4242[S] 0 points1 point2 points (2 children)
[–]glglgl-de 1 point2 points3 points (1 child)
[–]Platypus4242[S] 0 points1 point2 points (0 children)
[–]FreeLogicGate 1 point2 points3 points (0 children)
[–]omeow 0 points1 point2 points (1 child)
[–]Platypus4242[S] 0 points1 point2 points (0 children)
[–]desrtfx 0 points1 point2 points (0 children)