# Python Program to Convert Temperature from Celsius to Fahrenheit & Kelvin and Vice Versa

## Temperature Conversion

You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales. Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is
C = (F – 32) * 5/ 9

Formula to convert from Kelvin K to Celsius C is
C = K – 273.

Here “C”, “F”, “K” represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin Scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.

Input

The first line of the input contain a temperature Value in one of Celsius, Fahrenheit, and Kelvin scales.

Output

The first line of output should contain the Celsius value and the unit of the Celsius without any space.

The second line of output should contain the Fahrenheit value and the unit of the Fahrenheit without any space.

The third line of output should contain the Kelvin value and the unit of the Kelvin without any space.

Explanation

For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.

Sample Input 1
25C

Sample Output 1
25.0C
77.0F
298.0K

Sample Input 2
37.5F

Sample Output 2
3.06C
37.5F
276.06K

Code:

``````temperature=input()
length=len(temperature)
temp_value=float(temperature[:length-1])
temp_scale=temperature[-1]
c_to_f=round((temp_value*9/5)+32,2)
c_to_k=round(temp_value+273,2)
f_to_c=round((temp_value-32)*5/9,2)
f_to_k=round((temp_value-32)*5/9+273,2)
k_to_c=round(temp_value-273,2)
k_to_f=round(((temp_value-273)*9/5+32),2)

if "C" in temperature:
print(str(temp_value) + "C")
print(str(c_to_f) + "F")
print(str(c_to_k) + "K")
if "F" in temperature:
print(str(f_to_c) + "C")
print(str(temp_value) + "F")
print(str(f_to_k) + "K")
if "K" in temperature:
print(str(k_to_c) + "C")
print(str(k_to_f) + "F")
print(str(temp_value) + "K")

``````

Input
300.0K

Output
27.0C
80.6F
300.0K

## Python Program to Convert Integer into a Single Numeral

Single Digit Number Ram is given a positive integer N .He wishes to convert this integer into a single numeral. He does so by repeatedly adding the…

## Python Program to Print Armstrong numbers between two intervals￼

Write a program to print all the Armstrong numbers in the given range A to B (including A and B). An N – digit number is an…

## Python Program to Check if Given Input is a Letter, Digit or Special Character￼

Letter, Digit or Special Character You are given a character as input. Check if the given input is a Lowercase Letter or Uppercase Letter or Digit or…

## Interleave Strings | Python Program to merge two strings by adding characters in alternating order

Interleave Strings Given two strings, write a program to merge the given two strings by adding characters in alternating order, starting with the first string. If a…

## Python Program to Check if given colors are present in the color palate

Shekhar is an artist. He likes to draw and paint. He is now drawing a portrait of a city road which is in the black color and…

## Python Program to Check the eligibility criteria for donor

Python Comparison Operators An XYZ hospital has organised a blood donation camp. The eligibility criteria for donor was as follows  1) Age>=18  2) Weight >=50 kg  3)…