#๐ Problem with loop
28 messages ยท Page 1 of 1 (latest)
@stone moth
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Other than that everything works
oh shit
0.3/0.1 is 2.9999999999997
in the integer of that is 2
why?????
the calculator says 3
python says 2.99999997
that must be a python error!!!
so i need to use the round function then
int() just takes whatever float number you have and removes the decimals, it doesn't round
yes so ill use round instead
but i dont understand why python says that 0.3/0.1 is 2.999999999999997
because it is exactly 3
the real answer is exactly 3
computers use binary to represent numbers, you cannot have infinite number of binaries in your computer, so you cannot perfectly characterise every number
i see
good to know
so ill use round() instead
it rounds to nearest integer
thanks for your help @chrome zenith
greatly appreciated!
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Problem with loop