Last active 1 month ago

wowlikon's Avatar wowlikon revised this gist 1 month ago. Go to revision

No changes

wowlikon's Avatar wowlikon revised this gist 2 months ago. Go to revision

1 file changed, 2 insertions, 2 deletions

math_captcha.py

@@ -10,5 +10,5 @@ def capcha() -> ('question', 'answer'):
10 10 b, c = randint(0, 5), randint(0, 5)
11 11 return f"{b * c} {op} {b}", c
12 12
13 - if __name__ == '__main__':
14 - print(' = '.join(map(str, capcha())))
13 + if __name__ == '__main__':
14 + print(' = '.join(map(str, capcha())))

wowlikon's Avatar wowlikon revised this gist 2 months ago. Go to revision

1 file changed, 1 insertion, 1 deletion

math_captcha.py

@@ -4,7 +4,7 @@ from random import choice
4 4 def capcha() -> ('question', 'answer'):
5 5 op = choice(["+", "-", "*", "/"])
6 6 if op != "/":
7 - a, b = randint(0, 25), randint(0, 25)
7 + b, a = sorted(randint(0, 25), randint(0, 25))
8 8 q = f"{a} {op} {b}"
9 9 return q, eval(q)
10 10 b, c = randint(0, 5), randint(0, 5)

wowlikon's Avatar wowlikon revised this gist 2 months ago. Go to revision

1 file changed, 14 insertions

math_captcha.py(file created)

@@ -0,0 +1,14 @@
1 + from random import randint
2 + from random import choice
3 +
4 + def capcha() -> ('question', 'answer'):
5 + op = choice(["+", "-", "*", "/"])
6 + if op != "/":
7 + a, b = randint(0, 25), randint(0, 25)
8 + q = f"{a} {op} {b}"
9 + return q, eval(q)
10 + b, c = randint(0, 5), randint(0, 5)
11 + return f"{b * c} {op} {b}", c
12 +
13 + if __name__ == '__main__':
14 + print(' = '.join(map(str, capcha())))
Newer Older