-1

I'm just trying to create a slightly more complex temperature conversion program than I had as a homework assignment for practice with some of the concepts we are using in class at the moment, and I'mm running into an error I'm unfamiliar with. Unfortunately the searches I've run brought up various examples of if/ if... else statements but in much more complex circumstances and I was not able to find the answer to this particular issue. I'm new to Python but have some experience with basic to intermediate Javascript, so some things are somewhat similar to what I've seen. The error does not occur when option 1 is chosen, entered, and the conversion is executed. It only happens when option 2 is chosen and then conversion is supposed to take place. My code/output are as follows:

choice = int(input('Choose your conversion method. Press 1 for Celsius to Farenheit. Press 2 for Farenheit to Celsius.'))
if choice == 1:
celsTemp = float(input('Please input degrees in Celsius for conversion'))
farenTemp = (1.8 * celsTemp) + 32
print(str(celsTemp) + ' degrees Celsius is equal to: ' + str(farenTemp) + ' degrees Farenheit')
if choice == 2:
farenTemp = float(input('Please input degrees in Farenheit for conversion'))
celsiusTemp = (farenTemp - 32)(5) / 9
print(str(farenTemp) + ' degrees Farenheit is equal to: ' + str(celsiusTemp) + ' degrees Celsius')

the error I recieve is as I believe during the conversion step. This is the output:

Choose your conversion method.
Press 1 for Celsius to Farenheit.
Press 2 for Farenheit to Celsius.2
Please input degrees in Farenheit for conversion86
Traceback (most recent call last):
File "C:\Users\Jason\Desktop\Python files\test for temp program.py", line 8, in
celsiusTemp = (farenTemp - 32)(5) / 9
TypeError: 'float' object is not callable

JWK3986
  • 13
  • 3

2 Answers2

2

Multiplication in Python does not work by parentheses.

Replace

celsiusTemp = (farenTemp - 32)(5) / 9

With

celsiusTemp = (farenTemp - 32)*5 / 9

Dmitry Pleshkov
  • 1,147
  • 1
  • 13
  • 24
0

Your error in the line celsiusTemp = (farenTemp - 32)(5) / 9 is that you have omitted the multiply sign : celsiusTemp = (farenTemp - 32)*5 / 9. If not Python thinks that (farenTemp - 32) is a callable. Good explanation in this link.

Community
  • 1
  • 1
VdF
  • 34
  • 5