QUESTION IMAGE
Question
what is the output of the following code?
x = 10.5
y = int(x)
print(y)
10.5
10
11
error
Step1: Analyze the code
The code first assigns the float value \(10.5\) to \(x\). Then it uses the int() function on \(x\).
Step2: Understand the int() function
The int() function in Python truncates the decimal part of a float (it does not round). So for \(x = 10.5\), int(x) will give \(10\).
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
B. 10