python - How do I run another script, inside my main script -


i don't know how run script inside main python script. example:

index.py:

  category = "math"   print (category)   print ("you can use calculator")   print ("what 43.5 * 7")   #run calculator.py   answer = int(input("what answer")) 

how run calculator script inside of without having write calculator code inside of index script?

since other "script" python module (.py file) can import function want run:

index.py:

from calculator import multiply  # import multiply function calculator.py  category = "math" print(category) print("you can use calculator") print("what 43.5 * 7")  #run calculator.py real_answer = multiply(43.5, 7)  answer = int(input("what answer")) 

calculator.py

def multiply(a, b)     return * b 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -