make math test python code example

Example: how to make a set of math questions in python

import random
from datetime import datetime
import time

random.seed(time.time())

answerlist=[]

for i in range(1,26):
  sw = False
  f = random.randint(1,99)
  w = random.randint(1,99)
  if f >= 10 and w >= 10:
    sw = True

  while sw == False:
    f = random.randint(1,100)
    w = random.randint(1,100)
    if f >= 10 and w >= 10 and w <= 99 and f <= 99:
      sw = True
    
  
  print(str(i)+')',f,'+',w,'=')
  answerlist.append(f + w)

for i in range(1,26):
  print(answerlist[i-1])