Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the python code shown below for various styles of format specifiers?
x=1234
res=’integers:…%d…%-6d…%06d’ %(x, x, x)
res

What will be the output of the python code shown below for various styles of format specifiers?
x=1234
res=’integers:…%d…%-6d…%06d’ %(x, x, x)
res
a) ‘integers:…1234…1234 …001234’
b) ‘integers…1234…1234…123400’
c) ‘integers:… 1234…1234…00123400’
d) ‘integers:…1234…1234…001234’

Answer: a
Explanation: The code shown above prints 1234 for the format specified %d, ‘1234 ’ for the format specifier %-6d (minus ‘-‘ sign signifies left justification), and 001234 for the format specifier %06d. Hence the output of this code is: ‘integers:…1234…1234 …001234’

Join The Discussion