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 following Python code?
‘%s’ %((1.23,),)

What will be the output of the following Python code?
‘%s’ %((1.23,),)
a) ‘(1.23,)’
b) 1.23,
c) (,1.23)
d) ‘1.23’

Answer: a
Explanation: The formatting expression accepts either a single substitution value, or a tuple of one or more items. Since single item can be given either by itself or within the tuple, a tuple to be formatted must be provided as a tested tuple. Hence the output of the code is: >>> ‘%s’ %((1.23,),)

Join The Discussion