0

print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

Don't you have to do % second after /, +, and -?

Ex. 3 + 2 + 1 - 5 + (0) - (.25) + 6 = 6.75

Does Python round up to the nearest whole number?

jhpratt
  • 6,841
  • 16
  • 40
  • 50
Claire
  • 159
  • 1
  • 4
  • 15
  • 2
    Are you asking why, in Python 2, the first line of your question gives 7 rather than 6.75? – DavidG Apr 17 '18 at 22:24
  • yes, is that so, and how do i change that? – Claire Apr 17 '18 at 22:25
  • 1
    That's completely unrelated to order of operations. It's simply because python does integer division, so `1/4` equals 0. – Aran-Fey Apr 17 '18 at 22:26
  • Can't vote to close but here is a dupe - https://stackoverflow.com/questions/2958684/python-division – DavidG Apr 17 '18 at 22:30
  • Possible duplicate of [Python division](https://stackoverflow.com/questions/2958684/python-division) – tda May 04 '18 at 10:36

0 Answers0