how to make a python module or fuction and use it while writing other programs?
<p>There where many instances where i have to write large line of code over and over again in multiple programs. so i was wondering if i could write just one program, save it and then  call it in different programs like a function or a module.</p>

<p>An elementary example :- I write a program to check if a number is palindromic or not. Then i want to write a program to check if a number is a palindromic a prime, could i just call the first program and do the rest of the code to check if it is prime or not.</p>

<p>P.S I'm just a beginner at python or computer science for that matter and i use IDLE to do all my python programs.</p>

<p>it's easy to write a function in python.</p>

<p>first define a function is_palindromic,</p>

<pre><code>def is_palindromic(num):
    #some code here
    return True
</code></pre>

<p>then define a function is_prime,</p>

<pre><code>def is_prime(num):
    #some code here
    return True
</code></pre>

<p>at last, suppose you have a number 123321, you can call above function,</p>

<pre><code>num = 123321
if is_palindromic(num):
    if is_prime(num):
        print 'this number is a prime!'
</code></pre>

<p>ps, maybe you could try to use some editors like vscode or sublime.</p>

python function module