Hello in the past I made this python code that randomly generates an equation takes the user’s input and does it for a minute. This is the Python
import random
import time
correct=0
wrong=0
def random_problem(num_operations):
eq = str(random.randint(1, 100))
for _ in range(num_operations):
eq += random.choice(["+"])
eq += str(random.randint(1, 100))
return eq
start = time.time()
while True:
elapsed = time.time() - start
if elapsed > 60:
total_questions=correct+wrong
print(correct,"Correct",wrong,"Wrong,",total_questions," total questions")
break
problem = random_problem(1)
ask=int(input(problem +": "))
solution = eval(problem)
if ask == solution:
correct=correct+1
print("Correct")
else:
wrong=wrong+1
print("Wrong, the correct answer is",solution)
Now I want to put it on a website in Javascript. This is the Javascript code the I have so far
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
return(getRandomInt(10));
This randomly generates an equation. I would like help doing the other parts because I have not found a way to do the other parts Thanks.