Skip to main content

Python 2 and 3 differences

A Recent challangerecent challenge pushed me to search for differences in two major versions of pythonPython. More precisely - same code, code that returns different results in different versions. This might be helpful in other polyglot challenges.

  1. Strings and bytes comparissoncomparison
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?

Python 2 and 3 differences

Recent challange pushed me to search for differences in two major versions of python. More precisely - same code, that returns different results in different versions. This might be helpful in other polyglot challenges.

  1. Strings and bytes comparisson
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?

Python 2 and 3 differences

A recent challenge pushed me to search for differences in two major versions of Python. More precisely, code that returns different results in different versions. This might be helpful in other polyglot challenges.

  1. Strings and bytes comparison
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?
Small typo.
Source Link
user202729
  • 17.6k
  • 2
  • 39
  • 71

Python 2 and 3 differences

Recent challange pushed me to search for differences in two major versions of python. More precisely - same code, that returns different results in different versions. This might be helpfullhelpful in other polyglot challenges.

  1. Strings and bytes comparisson
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?

Python 2 and 3 differences

Recent challange pushed me to search for differences in two major versions of python. More precisely - same code, that returns different results in different versions. This might be helpfull in other polyglot challenges.

  1. Strings and bytes comparisson
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?

Python 2 and 3 differences

Recent challange pushed me to search for differences in two major versions of python. More precisely - same code, that returns different results in different versions. This might be helpful in other polyglot challenges.

  1. Strings and bytes comparisson
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?
Source Link
Dead Possum
  • 3.5k
  • 14
  • 25

Python 2 and 3 differences

Recent challange pushed me to search for differences in two major versions of python. More precisely - same code, that returns different results in different versions. This might be helpfull in other polyglot challenges.

  1. Strings and bytes comparisson
  • Python 2: '' == b''
  • Python 3: '' != b''
  1. Rounding (Luis Mendo answer)
  • Python 2: round(1*0.5) = 1.0
  • Python 3: round(1*0.5) = 0
  1. Division (Jonathan Allan answer)
  • Python 2: 10/11 = 0
  • Python 3: 10/11 = 0.9090909090909091
  1. Suggestions?