다른 프로그램에서 함수를 가져 오는 간단한 프로그램을 작성하고 있습니다. 그것은 기본적으로 화씨를 섭씨로 전환 시키거나 그 반대로, 당신이 어떤 종류의 의견을 주는지에 따라 다릅니다. 여기에 메인 프로그램의 코드이다 : 나는 그것을 할 갈 때누락되었습니다 1 temp에 대한 필요한 위치 인수
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)
, 그것은 온도 I 할게요 :
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()
가 그리고 여기에 기능을 가져 오는 프로그램의 코드의가에서오고있다 화씨와 섭씨의 구별을 받아 들일 것입니다. 그렇다면 다음과 같이 말할 것입니다 :
celsius() missing 1 required positional argument: 'temp'
저는 정말 이것을 이해할 수 없으므로 도움이 될 것입니다. 감사.
를 주'에서()'이 모두'화씨()를 호출'과 :
당신은 당신의 프로그램의 경우 0
을 얻을 것입니다 당신이 할 것 : 시도 celsius()'를 호출합니다. 이 인수는 두 기능 모두에 필요합니다. – elethan