Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 67 of 102
Marks: +1, -0
What will be the output of the following statement ?
print(6+5/4**2//5+8)
[CBSE 2024 Compartment]
Solution:  
Concept:
Precedence in Python: ** first, then *, /, //, % (left to right), then +, -. The operator / always gives a float, and // on a float gives a float.
Explanation:
Step 1: 4**2 = 16
Step 2: 5/16 = 0.3125
Step 3: 0.3125//5 = 0.0 (floor of 0.0625, kept as float)
Step 4: 6 + 0.0 + 8 = 14.0
Output:
14.0
The result is a float, so it is 14.0 and not 14.
Answer:
Option B (14.0)
© examsnet.com
Advertisements
Go to Question: