Random Files
Random Files
and Files
Dr. Baldassano
[email protected]
Yu’s Elite Education
Homework: Compute square
root of number
If r is the square root of X, then
r = X/r
Can find r by starting with a guess, then keep
averaging r and X/r
X = 10
r=1
r = (r + X/r)/2 = 5.5
r = (r + X/r)/2 = 3.659…
…
Random Numbers
import random
Main functions:
random.seed(a=None)
random.randint(a,b)
random.uniform(a,b)
random.shuffle(x)
Examples