0
can anyone explain how this pyton simplify? 10-3*2+2.0 the answer is 6.0 i need the explanation
5 Answers
+ 1
It's operator precedence. The 2*3 comes first and equals 6. 10-6+2.0, now go from left to right. The reason why it is 6.0 is because there is already a float number in there: 2.0. It's only to get the exact answer.
0
THANKS A LOT CAN U HELP ME WTIH BOOLEAN ALSO PLEASE?
0
What exactly do you need help on with boolean?
0
SIMPLIFICATIONS LIKE THIS EXPLANATIONS HOW THAT DOES ? THE REASONS BRO CAN U EMAIL A MSG TO MY EMAIL SO I CAN TELL ushan . wijesekara@gmail.com can u send a msg ??
0
As Katelyn mention, it's order precedence.
10-3*2+2.0
we do multiplication first
3*2 = 6
we end up with
10-6+2.0
then we proceed from left to right
10-6 = 4
4+2.0 = 6.0
The integer was converted to a float because had a float number in it.
am i right? :D