Classify each of the following expressions as legal or illegal. Each expression represents a call to a standard Python library function. (a) math.sqrt(4.5) (b) math.sqrt(4.5, 3.1) (c) random.rand(4) (d) random.seed() (e) random.seed(-1)
a) math.sqrt(4.5) is legal
The function will return the square root value of 4.5
b) math.sqrt(4.5,3.1) is illegal
The sqrt method only takes one argument as a parameter and returns its square root.
c) random.rand(4) is illegal
The random module doesn't have any funciton by the name of rand()
d) random.seed() is legal
The seed method is used to initialize the pseudorandom number generator in python.
e) random.seed(-1) is legal
Each time before calling random.random(), if we set the seed by some value, then the same number is given for that particular value every time.
Get Answers For Free
Most questions answered within 1 hours.