# [Tutor] Help me to print this formatted output

Alan Gauld learn2program at gmail.com
Tue Sep 6 12:44:16 EDT 2022

On 06/09/2022 17:26, Abhishek Yadav wrote:
> output should be like this
> Celsius   Fahrenheit   Kelvin
> 10           50.0             283.15

Yes and that's what I get(almost):

~/Desktop \$ python3 tmp.py
Enter temperature in celsius: 10
Celsius   Fahrenheit   Kelvin
10         50.0   283.15

You need to change the justification sign if you want it left aligned.

>
> On Tue, 6 Sept 2022 at 21:36, Alan Gauld via Tutor <tutor at python.org>
> wrote:
>
>     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
>
>
>
>
>     _______________________________________________
>     Tutor maillist  -  Tutor at python.org
>     To unsubscribe or change subscription options:
>     https://mail.python.org/mailman/listinfo/tutor
>
--
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