

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
i love you, you oped to me new world thanxxx
we have to raise an exception
Appreciate the effort you guys put in 🙂
when int is used with a float number, the fractional part gets removed, THEY ARE NOT ROUNDED OFF, AS MENTIONED IN THE VIDEO…
RIP long
These videos should have more views, they are so professional…
Your python tutorials are awesome !!!
It will be better if you will share the slides for this playlist ….Please …
Thanks in advance
This makes me want to watch Stargate..
great videos
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
How to clear the window with out using quit()
Love this channel!
Who tf disliked this video lmao??
Awesome videos! You can add exponent operator **, for example: 4**2 = 16
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))
I'm impressed how clear you made this topic.
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.
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