Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
3774 views
ubuntu2004
1
def generator():
2
x,y = var("x y")
3
4
# Genereate random line with slope -B/A
5
A = randrange(1,10)*choice([-1,1])
6
B = A
7
while A==B:
8
B = randrange(1,10)*choice([-1,1])
9
C = randrange(-9,10)
10
# standard equation
11
line1 = {
12
'equation': (A*x+B*y==C),
13
'slope': -B/A,
14
}
15
16
# Genereate random line with slope m
17
m = randrange(1,10)*choice([-1,1])
18
b = randrange(-9,10)
19
# slope-intercept equation
20
line2 = {
21
'equation': (y==m*x+b),
22
'slope': m,
23
}
24
25
lines = [line1,line2]
26
shuffle(lines)
27
28
return {
29
"lines": lines,
30
"alt_prompt": choice([True,False]),
31
}
32
33