Arifa
asked

Expert
Kelish Rai answered
When performing arithmetic operations in Python, the result will be a floating-point number if you use the / operator for division. For example, 5 / 2 will give you 2.5.
If you're using operations like addition (+), subtraction (-), or multiplication (*), the result will be in floating-point only if any of the values involved are floating-point numbers. For example, 5 + 2.2 will give you 7.2.
If you use the // operator for integer division, like 5 // 2, the result will be an integer (in this case, 2).
This distinction helps you get the result you expect, depending on the type of operation and the numbers involved.
Python
This question was asked as part of the Learn Python Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer