+ 1

arithmetic modules python

x=2 y=9 z=21 -x**2/2+4 why python give me result is 0 ? should it 0?

3rd Feb 2018, 12:07 AM
captainflint
captainflint - avatar
8 odpowiedzi
+ 3
It's the order of operations - not left to right, but exponentiation, multiplication/division, addition/subtraction
3rd Feb 2018, 12:19 AM
Jesse Bayliss
Jesse Bayliss - avatar
+ 2
3rd Feb 2018, 12:16 AM
Jesse Bayliss
Jesse Bayliss - avatar
+ 2
x+(y**2)-((y/x)+1) I'll update the other code to show it step by step too
3rd Feb 2018, 12:27 AM
Jesse Bayliss
Jesse Bayliss - avatar
+ 1
thanks
3rd Feb 2018, 12:27 AM
captainflint
captainflint - avatar
0
What result? You show 3 assignments but no calculations or print statements.
3rd Feb 2018, 12:11 AM
Jesse Bayliss
Jesse Bayliss - avatar
0
sorry calculation is -x**3/2+4
3rd Feb 2018, 12:11 AM
captainflint
captainflint - avatar
0
wow thanks but why we start at left ?
3rd Feb 2018, 12:17 AM
captainflint
captainflint - avatar
0
well ı have one question if x+y**2-(y/x+1) how its solve ?
3rd Feb 2018, 12:23 AM
captainflint
captainflint - avatar