Computer Science, asked by KoolKewin, 19 days ago

When we divide 10/3 in python, why does it show 3.3333333333333335?
It should be 3.3333...

Answers

Answered by mcchaturvedi98933891
0

Answer:

When you see the % symbol, you may think "percent". But in Python, as well as most other programming languages, it means something different.

The % symbol in Python is called the Modulo Operator. It returns the remainder of dividing the left hand operand by right hand operand. It's used to get the remainder of a division problem.

The modulo operator is considered an arithmetic operation,

Explanation:

hope it will help

Answered by Ace0615
0

Answer:

10/3 is 3 whole 1/3 or in decimals 3.333333.... .

But when you type 10/3 in python or in any programming language, it shows 3.3333333333333335 as it depends on the data type you choose i.e. float. So it takes out the result as far as it can store its value in float and if its value in infinite, then it rounds of the last number.

For example 3.3333333333333333333333etc. can be written as 3.335 or 3.333335 and so on. But 3.3333333333333335 is the maximum limit of float types which it cannot exceed. Thus it rounds of the last number to 5.

You can also try this in your phone calculator, the result will be short but either 5 or 3 will be at the end, graranteed!!

It all depends how you program.

Hope you understood the reason, cheers:)

Similar questions