0

can anyone explain how this pyton simplify? 10-3*2+2.0 the answer is 6.0 i need the explanation

4th Oct 2016, 6:51 AM
Ushan Wijesekara
Ushan Wijesekara - avatar
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.
4th Oct 2016, 7:07 AM
Katelyn
0
THANKS A LOT CAN U HELP ME WTIH BOOLEAN ALSO PLEASE?
4th Oct 2016, 7:10 AM
Ushan Wijesekara
Ushan Wijesekara - avatar
0
What exactly do you need help on with boolean?
4th Oct 2016, 7:13 AM
Katelyn
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 ??
4th Oct 2016, 7:16 AM
Ushan Wijesekara
Ushan Wijesekara - avatar
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
12th Oct 2016, 11:19 PM
Ricardo Rico
Ricardo Rico - avatar