What will be the output of the following Python code? [code] D=dict(p='san', q='foundry') '{p}{q}'.format(**D)[/code]

What will be the output of the following Python code?
Code:
 D=dict(p='san', q='foundry')
'{p}{q}'.format(**D)
A. Error
B. 123hoidap
C. san foundry
D. {‘san’, ‘foundry’}
 
Answer: b
Explanation: The code shown above prints the values substituted for p and q in the same order. Note that there is no blank space between p and q. Hence the output is: 123hoidap.
 

Tìm kiếm

Back
Top