-1

I am encountering the following issue with python 3

erg = (545-1023)/25971
erg = -1

in the link below is a screenshot.

I don't encounter this problem if I run my code on a different machine.

https://i.stack.imgur.com/CGi75.jpg

khelwood
  • 55,782
  • 14
  • 81
  • 108
Anthony Haake
  • 27
  • 1
  • 4

1 Answers1

1

Are you sure you're on Python 3 when you get -1? That was the old behavior from Python 2. Try this:

from __future__ import (print_function, division)
erg = (545-1023)/25971
print(erg)  # -0.018405144199299218

import platform
print(platform.python_version())  # what's here? Python 2.x? Or 3.x?
mattmc3
  • 17,595
  • 7
  • 83
  • 103
  • this import is changing my results! fantastic – Anthony Haake May 27 '17 at 19:03
  • i am confused because the platform.pythonversion shows 2.7.1 but my ipython kernel in jupyter shows 3 – Anthony Haake May 27 '17 at 19:04
  • Welcome to StackOverflow. If you would, please mark mine as the answer to your question. Also, were you on Python 2 accidentally? – mattmc3 May 27 '17 at 19:05
  • Without more information, I'm not sure I can say for sure, but Jupyter used to be ipython notebook, and still (for now) will let you launch using `ipython3 notebook`. Try `ipython3` and see how that works out for you. If it doesn't, ask another question on SO and provide the details and I bet you get the answer. – mattmc3 May 27 '17 at 19:08