하나의 함수에서 다른 함수로 변수를 호출하는 쉬운 방법이 있습니까?다른 함수의 변수 호출
def getInput():
dist=int(input("Enter the distance [m]: "))
time=input("Enter the time [min]: ")
convDist(dist,time)
def convDist(dist,time):
miles=dist*.0006214
yards=dist*1.094
feet=dist*3.281
inches=dist*39.37
km=dist*.001
print("Original distance: ",dist)
print("= ",miles," mi")
print("= ",yards," yd")
print("= ",feet," ft")
print("= ",inches," in")
print()
convTime(time)
def convTime(time):
time=float(time)
seconds=time*60
hours=time/60
calcSpeed(hours,seconds)
def calcSpeed(hours,seconds):
ms=dist/seconds
yds=yards/seconds
kmhr=km/hours
mihr=miles/hours
print("Your distance and time give speeds of:\n"
,m,"m/s",yds,"yd/s",kmhr,"km/hr",mihr,"mi/hr")
def main():
getInput()
main()
나는 데 문제 :
1 Enter the distance [m]: 400
2 Enter the time [min]: 0.7197
3
4 Original distance: 400 m
5 = 0.2486 mi
6 = 437.6 yd
7 = 1312.4 ft
8 = 15748.0 in
9
10 Your distance and time give speeds of:
11 9.26 m/s, 10.13 yd/s, 33.35 km/hr, and 20.73 mi/hr.
는 내가 지금까지 가지고하는 것은 이것이다 : 나는 출력이 다음과 같이하도록되어 거리/시간/속도 변환 프로그램을 만들려고 노력하고 있어요 첫 번째 함수에서 calcSpeed () 함수에 숫자 (입력)를 가져와 속도를 계산할 입력이 필요합니다.
그들은 당신이 이제까지 아무 것도 반환되지 않는 것 같습니다 람다 목록 (매개 변수 목록) – BRFennPocock
에 추가 하시겠습니까? – Trent