1.

The output of which of the codes shown below will be: “There are 4 blue birds.”?(a) ‘There are %g %d birds.’ %4 %blue(b) ‘There are %d %s birds.’ %(4, blue)(c) ‘There are %s %d birds.’ %[4, blue](d) ‘There are %d %s birds.’ 4, blueThe question was posed to me by my school teacher while I was bunking the class.I would like to ask this question from Formatting in division Formatting & Decorators of Python

Answer»

Correct answer is (B) ‘There are %d %s birds.’ %(4, blue)

Easy explanation - The code ‘There are %d %s birds.’ %(4, blue) results in the output: There are 4 blue birds. When we INSERT more than one value, we should group the VALUES on the RIGHT in a tuple.



Discussion

No Comment Found