What will be the output of the following Python expression if x=56.236? print(“%.2f”%x)

Questions & AnswersCategory: Programming LanguageWhat will be the output of the following Python expression if x=56.236? print(“%.2f”%x)
Geek Boy Staff asked 2 years ago
1 Answers
Geek Boy Staff answered 2 years ago

d. 56.24
Explanation: The expression shown above rounds off the given number to the number of decimal places specified. Since the expression given specifies rounding off to two decimal places, the output of this expression will be 56.24. Had the value been x=56.234 (last digit being any number less than 5), the output would have been 56.23.