Python output float / integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python output float / integer

x = 2 x \=2 print(x) Gives output 1.0 and if we want output 1 then why can't we do like x = 2 x\\=2 print(x)

27th Jul 2019, 9:59 AM
Dhyey Badheka
Dhyey Badheka - avatar
2 Answers
+ 7
You can do so. But if x = 3 x /= 2 >>>>1.5 x = 3 x //= 2 >>>>1
27th Jul 2019, 10:20 AM
Mikhail Gorchanyuk
Mikhail Gorchanyuk - avatar
+ 4
You might be confusing '\' for '/'. Both /= and //= operators work as intended. x = 2 x //= 2 print(x) will give you an output of 1.
27th Jul 2019, 10:16 AM
Hatsy Rei
Hatsy Rei - avatar