Tag: Formatting

  • Python Quizs Question and Answers – Formatting – 2

    Q 1. The output of which of the codes shown below will be: “There are 4 blue birds.”?A. ‘There are %g %d birds.’ %4 %blueB. ‘There are %d %s birds.’ %(4, blue)C. ‘There are %s %d birds.’ %[4, blue]D. ‘There are %d %s birds.’ 4, blue Show Answer Answer:-B. ‘There are %d %s birds.’ %(4,…

  • Python Quizs Question and Answers – Formatting – 1

    Q 1. What will be the output of the following Python expression if x=456? print(“%-06d”%x) A. 000456B. 456000C. 456D. error Show Answer Answer:-C. 456 Explanation The expression shown above results in the output 456. Q 2. What will be the output of the following Python expression if S=345? print(“%06d”%S) A. 345000B. 000345C. 000000345D. 345000000 Show…

  • Python Quizs Question and Answers – Advanced Formatting Tools

    Q 1. The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.A. first, rightB. second, leftC. first, leftD. second, right Show Answer Answer:-B. second, left Explanation The formatting method {1:>> ‘%s’ %((1.23,),). Q 10. What will be the output of the following two codes? i. ‘{0}’.format(4.56) ii. ‘{0}’.format([4.56,])…

You cannot copy content of this page