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…

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!! ๐๐ฆ

a lot to remember hopefully I get this.

Another "interesting" difference between python 2 and 3:

python3: (2+2j)//2 -> TypeError: can't take floor of complex number.

python2: (2+2j)//2 -> (1+0j) # seems like they only truncated the real part

HEEELLLLLLP! http://bit.ly/PythonKickstarter

DEADLINE SUNDAY OCT 20th

good presentation easy and simple to understand .

We're halfway there. We still need your help! Support Socratica Python Kickstarter: http://bit.ly/PythonKickstarter

Support what you love! Socratica has a Kickstarter to make more Python: http://bit.ly/PythonKickstarter

Can python do powers and radicals?

It sez:

>>> z = 7.1j

>>> z.real

0.0

>>> z.imag

7.1

>>> z + 5

(5+7.1j)

>>>

Great tutorial

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

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??

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 V3Hello, 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