I'm writing a simple program that imports functions from another program. It basically converts Fahrenheit to Celsius or vice versa, depending on what kind of input you give it. Here's the code for the main program:
def main():
temp = int(input('What is the temperature? '))
print('Is this temperature in fahrenheit or celsius?')
system = int(input('Please put 1 for Fahrenheit and 2 for Celsius: '))
if system == 1:
from tempconvert import celsius
celsius()
elif system == 2:
from tempconvert import fahrenheit
fahrenheit()
else:
print('I dont understand.')
main()
And here's the code for the program the functions being imported are coming from:
def fahrenheit(temp):
fahrenheit = temp * 1.8 + 32
print('Your temperature in fahrenheit is ', fahrenheit)
def celsius(temp):
celcius = temp - 32
celsius = celcius / 1.8
print('Your temperature in celsius is ', celsius)
When I go do it, it'll take the temperature I enter, and it'll accept the distinction between Fahrenheit and Celsius. But then it'll say this:
celsius() missing 1 required positional argument: 'temp'
I really cannot figure this out, so any help would be appreciated. Thanks.
main()you call bothfahrenheit()andcelsius()without thetempargument. This argument is required for both functions. - elethan