python modules Flashcards
math
math.pi
math.e
math.ceil
math.floor
math.pow
math.sqrt
math.factorial
os
os.getcwd- current working directory
cwd- current working directory
os.environ- dictionary of environments
examples: identify current user or path variable- identify the path
os.listdir- all current files and directories
os.mkdir- make temp directory in current working directory
os.rename- rename directory
os.rmdir- remove directory
os.path.isdir(cwd)- pass in a name, it will tell you whether it is a directory or not. it returns true value if it a directory
os.path.isfile(cwd)- indicates the file exists
from os module you can import path
path.exists- checks for existence of directory or a file
Random module
random.random() gives u a random number 0.6123567…
again if you do random.random() it again gives u another random number
random.randint - generates random integers(0,10)— it can be any integer
** you have to specify the integer range
random.choice(my_list) - will generate random element from the list
datetime module
datetime.date.today()—-today’s date
datetime.datetime.now – will give date, time upto nano second