Edited, memorised or added to reading queue

on 09-Jul-2025 (Wed)

Do you want BuboFlash to help you learning these things? Click here to log in or create user.

Flashcard 7714232470796

Tags
#pytest #python #unittest
Question
[...] 0.1 + 0.1 + 0.1 == 0.3, "Usual way to compare does not always work with floats!"
Answer
assert

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Parent (intermediate) annotation

Open it
assert 0.1 + 0.1 + 0.1 == 0.3, "Usual way to compare does not always work with floats!"

Original toplevel document

Open it
Beware of float return values! 0.1 + 0.1 + 0.1 == 0.3 Sometimes false assert 0.1 + 0.1 + 0.1 == 0.3, "Usual way to compare does not always work with floats!" Instead use: assert 0.1 + 0.1 + 0.1 == pytest.approx(0.3)