Python Module in Python

Package is a folder which consists of modules and sub-packages.Modules are used to break down large programs into manageable (small) and organized files. Furthermore, modules provide reusability of code.

There are two types of modules we use in the program.

  • In-built Module

Date Time Module-

The datetime module used to get a specific date or time by calling this module.

Program:

import datetime
print(datetime.datetime.now())

Output:

2020-05-24 14:32:42.675491

Calendar Module –

This module can find any date ,day easily.

Program:

import calendar
year=int(input("Enter The Year"))
mont=int(input("Enter the month"))
print(calendar.month(year,mont))

Output:

Enter The Year1999
1999
Enter the month3
3
     March 1999
Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Password Module:

This module protects text from unauthorised use.

import getpass
a=getpass.getpass()
print("Your Password is",a)

Output:

Your Password is abc

Compile File Module-

Using the module you can find the pyc file from py by import py_compile module.

Program:

import py_compile
>>> py_compile.compile("hello.py")
'__pycache__\\hello.cpython-38.pyc'
Subscribe Now