Computer Science, asked by ProximaNova, 5 hours ago

 \Large \dag \tealB{ \widetilde {Question} }
Predict the output of the following in python:
 \tt{print(0.1+0.2==0.3)}
\odotTrue
\odotFalse
\odotMachine dependent
\odotError​

Answers

Answered by prasadnijai212
4

Answer:

False

Explanation:

Because in python 0.1 +0.2 is not 0.3 ot is 0.300000...

therefore, it cannot be equal. You can format the addition till 1 decimal place, to get the ans as 0.3.

Answered by tname3345
5

Explanation:

given :

  • Predict the output of the following in python:
  • \tt{print(0.1+0.2==0.3)}print(0.1+0.2==0.3)

answer :

  • it is false because 0 because you are using '+' which is used to concatenate the string for example (“ shall + do ) the output will be shalldo

  • In your script 0.2==0.3 checked and give output as False.

  • So if want to check wether 0.1+0.2==0.3 and your desired output is True or 1 then add paranthesis then your line will be

  • output = ((0.1+0.2)==0.3)
Similar questions