Python

Arithmetic in Python V2 || Python Tutorial || Learn Python Programming



Today we talk about the rules of arithmetic in Python Version 2. The key detail is when combining two numbers, Python will widen numbers to make sure they are all of the same type. (In Python v2, there are four numeric types: ints, longs, floats and complex numbers.) Also, when you divide two whole numbers, Python will return the quotient, not the mathematical value.

And beware of division by 0!

To learn Python, start our Python Playlist HERE:

Subscribe…

Similar Posts

24 thoughts on “Arithmetic in Python V2 || Python Tutorial || Learn Python Programming
  1. Your division example is wrong.
    Python2.x rounds to the left, it does not produce the quotient.
    -5/2 = -3 compared to 5/2 = 2. It is massively stupid….
    Get around this by starting the code with "from _future_ import division"

  2. It's official! The Socratica Python Kickstarter was a success! Thank you to all of our supporters. Because of you, many more Python videos coming soon!! 💜🦉

  3. @Soratica maybe use the term Rations instead of Reals @2:43 as I do not believe that python can represent a Real number only an approximate thereof or its Rational equivalent.
    thanks for the amazing content!

  4. Why doesn't Python have small number types like bytes. Aren't those number types easier on the processor/memory when doing a lot of small number calculations under 255? I've made a habit of doing that in Java.

  5. I loved the videos of python 
    but can you make the videos of c++ i will be help full for many people all around the world 
    python is a high level coding language so i would like to learn c++ from your youtube channel 

Leave a Reply

Your email address will not be published. Required fields are marked *