python modules Flashcards

1
Q

math

A

math.pi
math.e
math.ceil
math.floor
math.pow
math.sqrt
math.factorial

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

os

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Random module

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

datetime module

A

datetime.date.today()—-today’s date

datetime.datetime.now – will give date, time upto nano second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly