python modules list code example

Example 1: modules in python

#use import statement to import modules
import random
r = random.randint(1,10)
#use from-import statements to import functions
from random import randint
r = randint(1,10)
#use from module import * statement to import all functions
from random import *
r = randint(1,10)

Example 2: modules in python

import numpy as np:

Example 3: modules in python

import  pandas as pd:

Example 4: cool python imports

import this
# Prints out the Zen of Python which contains 19 principles that influence the development in python.

Example 5: modules in python

import pyttsx3 # using ptython  to convert  text to speech

Example 6: python standard library

>>> from datetime import timedelta
>>> delta = timedelta(
...     days=50,
...     seconds=27,
...     microseconds=10,
...     milliseconds=29000,
...     minutes=5,
...     hours=8,
...     weeks=2
... )
>>> # Only days, seconds, and microseconds remain
>>> delta
datetime.timedelta(days=64, seconds=29156, microseconds=10)