Robotics & Artificial Intelligence

Predict the output of the following snippet:

a=42.85
b=int(a)
print(b)

Python Functions

1 Like

Answer

Output
42
Explanation

The int() function takes a floating-point value and truncates the decimal part to return an integer. Hence, 42.85 becomes 42 and is stored in b, which is then displayed.

Answered By

3 Likes


Related Questions