What will be the output of the following Python code? [code]'{a}{b}{a}'.format(a='hello', b='world')[/code]

Giang Phạm

New member
What will be the output of the following Python code?
Code:
'{a}{b}{a}'.format(a='hello', b='world')
A. ‘hello world’
B. ‘hello’ ‘world’ ‘hello’
C. ‘helloworldhello’
D. ‘hello’ ‘hello’ ‘world’
 
Answer: c
Explanation: The code shown above prints the values substituted for a, b, a, in the same order. This operation is performed using the format function. Hence the output of the code is: ‘helloworldhello’.
 

Tìm kiếm

Back
Top