Next Index Previous

Python Examples

21. Python Module example.

mylib.py
----------
def even(n):
	if n%2==0:
		print('Even number')
	else:
		print('Not Even')
		
def positive(n):
	if n>0:
		print('Positive number')
	else:
		print('Not Positive')	
		
def add(a,b):
	print(a+b)
    
example1.py
-------------
import mylib

mylib.even(77)
mylib.positive(-34)

example2.py
-----------
from mylib import even

even(77)
positive(-34)

example3.py
------------
from mylib import *

even(77)
positive(-34)    
Output :
Not Even
Not Positive




Father of Python Language

Guido-van-Rossum

Guido van Rossum

Born: January 31, 1956, Netherlands
Google+