Computer Science, asked by Agambhir5587, 11 months ago

How to format numbers to strings in Python?

Answers

Answered by nishitadeka82
2

HOLA BUDDY....

\huge\pink{Answer}

Python 2.6+

It is possible to use the format() function, so in your case you can use:

return '{:02d}:{:02d}:{:.2f} {}'.format(hours, minutes, seconds, ampm)

There are multiple ways of using this function, so for further information you can check the documentation.

Python 3.6+

f-strings is a new feature that has been added to the language in Python 3.6. This facilitates formatting strings notoriously:

return f'{hours:02d}:{minutes:02d}:{seconds:.

#hope it helps you....

Plzz mark it as brainliest... ^·^


gowthamcrontecpausiq: huh?
gowthamcrontecpausiq: whag
gowthamcrontecpausiq: what*
gowthamcrontecpausiq: r u her partner?
gowthamcrontecpausiq: yah bri
gowthamcrontecpausiq: bro*
Answered by Anonymous
0

Python 2.6+

It is possible to use the format() function, so in your case you can use:

return '{:02d}:{:02d}:{:.2f} {}'.format(hours, minutes, seconds, ampm)

There are multiple ways of using this function, so for further information you can check the documentation.

Similar questions