Temperature Convert Class
Programming Interview
Easy
8 views
Problem Description
Celsius value is provided. Create Temperature class with method to_f(). Output Fahrenheit with 2 decimals.
Input Format
One number C.
Output Format
One number F.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
C=float(s)
class Temperature:
def __init__(self,c):
self.c=c
def to_f(self):
return self.c*9.0/5.0+32.0
sys.stdout.write(f'{Temperature(C).to_f():.2f}')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!