Arithmetic in Python V3 || Python Tutorial || Learn Python Programming

///Arithmetic in Python V3 || Python Tutorial || Learn Python Programming

Arithmetic in Python V3 || Python Tutorial || Learn Python Programming

FavoriteLoadingAdd to favorites

Today we talk about the rules of arithmetic in Python Version 3. The key detail is when combining two numbers, Python will widen numbers to make sure they are all of the same type. (In Python v3, there are three numeric types: ints, floats and complex numbers.) And division has changed from version 2. Now, division always returns the correct math value as a float. It no longer returns the quotient when you divide two whole numbers.

And beware of division by 0!

➢➢➢➢➢➢➢➢➢➢
We recommend:
Python Cookbook, Third edition from O’Reilly

The Mythical Man Month – Essays on Software Engineering & Project Management

Shop Amazon Used Textbooks – Save up to 90%

➢➢➢➢➢➢➢➢➢➢
Subscribe to Socratica:

To support more videos from Socratica, visit
Socratica Patreon

Socratica Paypal

We also accept Bitcoin! 🙂
Our address is: 1EttYyGwJmpy9bLY2UcmEqMJuBfaZ1HdG9

➢➢➢➢➢➢➢➢➢➢
Python instructor: Ulka Simone Mohanty
Written & Produced by Michael Harrison
FX by Andriy Kostyuk

source

By |2019-07-02T20:20:30+00:00July 2nd, 2019|Python Video Tutorials|17 Comments

17 Comments

  1. Ahmed Ahmed July 2, 2019 at 8:20 pm - Reply

    i love you, you oped to me new world thanxxx

  2. 1 conscience 0 dimension July 2, 2019 at 8:20 pm - Reply

    we have to raise an exception

  3. Ghaz T July 2, 2019 at 8:20 pm - Reply

    Appreciate the effort you guys put in 🙂

  4. Krishnendu Bhattacharjee July 2, 2019 at 8:20 pm - Reply

    when int is used with a float number, the fractional part gets removed, THEY ARE NOT ROUNDED OFF, AS MENTIONED IN THE VIDEO…

  5. Az0dd July 2, 2019 at 8:20 pm - Reply

    RIP long

  6. T DJ July 2, 2019 at 8:20 pm - Reply

    These videos should have more views, they are so professional…

  7. Kiran Shah July 2, 2019 at 8:20 pm - Reply

    Your python tutorials are awesome !!!

    It will be better if you will share the slides for this playlist ….Please …

    Thanks in advance

  8. David Jamriska July 2, 2019 at 8:20 pm - Reply

    This makes me want to watch Stargate..
    great videos

  9. ALGORITHM KID July 2, 2019 at 8:20 pm - Reply

    MY question is why we cant convert complex numbers into floats ? like DUh just add -0j in the complex number you will get the float back simple logic. pls reply

  10. arindom das July 2, 2019 at 8:20 pm - Reply

    How to clear the window with out using quit()

  11. 王玮 July 2, 2019 at 8:20 pm - Reply

    Love this channel!

  12. Auzirk July 2, 2019 at 8:20 pm - Reply

    Who tf disliked this video lmao??

  13. Fernando Suyama July 2, 2019 at 8:20 pm - Reply

    Awesome videos! You can add exponent operator **, for example: 4**2 = 16

  14. wolfedog99 July 2, 2019 at 8:20 pm - Reply

    At 1:10 it is stated that the float is rounded then made into an int. This is incorrect, the float is truncated then made into an int, as such using int() to convert 3.2 or 3.8 will return 3 and -3.2 or -3.8 will return -3. Which is consistent with normal integer arithmetic.
    To round and convert you must use round()[yields 3, 4, -3,- 4],
    for more control import "math" and use math.ceil()[yields 4 ,4, -3, -3] or math.floor() [yields 3, 3, -4, -4]
    Also to get [4, 4, -4, -4] using the above inputs: int(math.copysign(math.ceil(abs(g)), g))

  15. Tommy Kelly July 2, 2019 at 8:20 pm - Reply

    I'm impressed how clear you made this topic.

  16. yvrelna July 2, 2019 at 8:20 pm - Reply

    Small suggestion: the terminology narrower and wider is, in my opinion, a bit of a misnomer, because Python allows arbitrary sized integers but only allows fixed size for floats and complex numbers. This means that in some sense integers are wider than floats and complex numbers.

  17. Socratica July 2, 2019 at 8:20 pm - Reply

    Arithmetic in Python V3

    Hello, hello! Our latest Python tutorial is on arithmetic in Python V3.  The main difference between V2 and V3 is that whole number division in V3 returns the correct value as a float, while in V2 it returns the quotient.

    More videos are coming soon!

    #LearnMore

Leave A Comment

*