[Tutor] Help me to print this formatted output
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Sep 6 12:06:10 EDT 2022
On 06/09/2022 13:18, Abhishek Yadav wrote:
> celsius = float(input('Enter temperature in celsius: '))
>
> # Converting
> fahrenheit = 1.8 * celsius + 32
> kelvin = 273.15 + celsius
> gap = " "*3
> # Displaying output
> print(f"{'Celsius':7s}{gap}{'Fahrenheit':10s}{gap}{'Kelvin':6s}")
> print(f"{celsius:7.0f}{gap}{fahrenheit:10.1f}{gap}{kelvin:6.2f}")
>
>
> out put : --
>
> Enter temperature in celsius: 10
> Celsius Fahrenheit Kelvin
> 10 50.0 283.15
Works fine for me. are you sure you have a monospace
font in your display?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list