0% found this document useful (0 votes)
3 views1 page

Python Modules: datetime & math Usage

Uploaded by

jewelajah810
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Modules: datetime & math Usage

Uploaded by

jewelajah810
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1. datetime module.

import datetime # We use import keyword to call that module and access the function
inside it using .(dot) operator.
x = [Link]() # datetime module is further having a datetime function
which is having now() function.
print(x)
y = dir(datetime) # dir() is used to find all the function names and variable name
of that module.
print(y)

2. math module

import math

x = [Link](100)
y = dir(math)

print(x)
print(y)

Let's say a name of module is very big and complex so in that case we can use 'as'
# when we import a module so that we don't have to write that name again and again.

import datetime as d

y = [Link]() #Here we have used d instead of datetime

print(y)

# If we have to use only date function from datetime we can only import that using
'from'

from datetime import date # Here we have only imported date function from datetime.

y=[Link]()

print(y)

You might also like