In the first case, the following operations are performed. 1º Captures a value in the "string" type. 2º Converts the captured value to "integer", inserts it in the formula, performs the calculation and stores the result in the variable "tempC" converted to "float" (implicit conversion. For every "/" division operation produces a float value). 3º Converts the value of the stored variable to "tempC" for "string" and then displays it.
In the second case, the following operations are performed. 1º Captures a value in the "string" type. 2º Convert the captured value to "integer", insert it in the formula, perform the calculation and store the result in the variable "tempC" converted to "float" (implicit conversion, as I said). 3º Calls the "format" function (although it is not passing the formatting parameters) to display the value of the variable stored in "tempC".
In the first case, you are using the "str()" function twice (separately).
In the second case, you are only using once the function "str()".
Converting a variable to a string requires more computational resources. When you call this function two or more times in an algorithm, you make it less efficient.
For programs with small amounts of variables, performance will not be substantially changed, but for programs that need to manipulate large numbers of variables, performance will be affected abruptly.
Another thing, in Python 3, more precisely from version 3.6, we can display the output result in several ways. Using your code with some modifications that I think relevant, we can display the output (output) in various ways
Example 1
tempF = int(input('Temperatura em graus Farenheit: '))
tempC = (((5 * tempF) - 32) / 9)
print('Temperatura em graus Celsius: '.format(tempC))
Example 2
tempF = int(input('Temperatura em graus Farenheit: '))
tempC = (((5 * tempF) - 32) / 9)
print(f'Temperatura em graus Celsius: {tempC}')
In this case we use "f-Strings", which is nothing more than a format supported by Python interpreters of versions equal to or greater than 3.6.
Example 3
tempF = int(input('Temperatura em graus Farenheit: '))
tempC = (((5 * tempF) - 32) / 9)
print(temC)
This is another way to display the answer without much embellishment.
Example 4:
from sys import stdout
tempF = int(input('Temperatura em graus Farenheit: '))
tempC = str(((5 * tempF) - 32) / 9)
stdout.write(tempC)
Example 5º:
tempF = int(input('Temperatura em graus Farenheit: '))
tempC = ((5 * tempF - 32) / 9)
print(f'Temperatura em graus C°: {tempC:.2f}')
In this case we are formatting the output value to two decimal places
I don’t know if it gets duplicated, but there’s an explanation here. Basically,
format
ends up callingstr
"behind the scenes"– hkotsubo