+ 1

what is happening in the last line,how is %0.3f is replacing both values?

num = 8 num_sqrt = num ** 0.5 print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))

21st Nov 2018, 2:47 AM
partha
partha - avatar
3 Respostas
+ 3
You can completely take out the 0.3 because it means nothing. The %f is acting as a placeholder for values that are to be added. f stands for format, so you are formatting the values num and num_sqrt into the printed string in the order they are listed
23rd Nov 2018, 5:20 AM
Pete Cowling
Pete Cowling - avatar
+ 2
Absolutely partha
23rd Nov 2018, 5:34 AM
Pete Cowling
Pete Cowling - avatar
+ 1
thanks Peter C...
23rd Nov 2018, 5:21 AM
partha
partha - avatar