0
def convertFarenheit(n):
return (n * (9/5)) + 32
def convertCelsius(n):
return (n - 32) * (5/9)
def graus(temp1,escala1,temp2,escala2):
dados = ()
if escala1 == 'C' and escala2 == 'C':
soma = temp1 + temp2
dados = (soma, 'C')
elif escala1 == 'F' and escala2 == 'F':
soma = temp1 + temp2
dados = (soma, 'F')
elif escala1 == 'F' and escala2 == 'C':
soma = convertCelsius(temp1) + temp2
dados = (soma, 'C')
elif escala1 == 'C' and escala2 == 'F':
soma = convertFarenheit(temp1) + temp2
dados = (soma, 'F')
return dados
def main():
temp1 = float(input())
escala1 = input().upper()[0]
temp2 = float(input())
escala2 = input().upper()[0]
print(graus(temp1,escala1,temp2,escala2))
if __name__ == '__main__':
main()
Examples of entries:
- temp1 = -84.6
- escala1 = F
- temp2 = 15.7
- scala2 = C
Return will be : (-49.077777777777, 'C').
Put fstring f{soma:.4f}
to be able to round off to 4 decimal places will return : ('-49.0778', 'C'), but I do not want to return with the quotes in the float.
Welcome to Stack Overflow! Please explain the problem better as your question is not noticeable. See Help Center How to Ask.
– Leticia Rosa
I’ve already made the change
– rick