이 간단한 프로그램을 실행하는 데 문제가있는 것처럼 보입니다. 기본적으로 내가하고 싶은 것은 함수 큐브의 숫자를 입력하는 것입니다. 그 숫자가 3으로 나눌 수 있는지 확인하십시오.파이썬에서 정말 간단하게 작동합니다.
print "This program checks if a number is divisible by three"
def cube(number): # this is my function which is defined
return number**3 # I am confused about the return. does the program exit?
print number
if number%3==0:
print "Yes"
else:
print "No"
인쇄 else : 인쇄 "아니요" – user4081147
왜 그 번호를 큐브합니까? –
프로그램이 종료되지 않지만 기능이 종료됩니다. 또한 결코 함수를 호출하지 않습니다. 튜토리얼을 읽으십시오 : https://docs.python.org/2/tutorial/controlflow.html#defining-functions – jonrsharpe