Why does 9**(1/2) produce float and 8**2 doesn't? Please explain. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Why does 9**(1/2) produce float and 8**2 doesn't? Please explain.

Hi, I am new to Python and am getting confused in why one expression produces integer while other produces float? Please explain.

24th Mar 2022, 9:34 PM
Ruchika Sehgal
Ruchika Sehgal - avatar
1 ответ
+ 1
9**(1/2) means 9**0.5 float calculation 8**2 => 8*8 integer calculation automatically upcasted to higher types
24th Mar 2022, 9:42 PM
Jayakrishna 🇮🇳