Calling and creating a function in python
Question: I'm fairly new to python (still in the first few chapters of an introductory
book) and i was wondering, once i have defined a function and saved it in
script mode, and i want to use it in another script do i have to define it the
new program?

To clarify suppose a create a function `multiplybyfive(x)` which takes an
input and x and returns 5x. Now suppose i create a program which uses
`multiplybyfive(x)` in it, do i have to define it again in this new program or
can i simply call it somehow?


Answer: You can import the python file which contains function multiplybyfive(x) into
your new file.

For example, if you write multiplybyfive(x) in file mathfunction.py file. You
can use it in a new program by

    
    
    from mathfunction import multiplybyfive
    
    x = 1
    y = multiplybyfive(x)
    print y
    

