You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ExamGenerator/src/senior_generator.py

16 lines
511 B

import random
from base_generator import BaseQuestionGenerator
class SeniorQuestionGenerator(BaseQuestionGenerator):
def generate_question(self):
ops = ["+", "-", "*", "/"]
num_operands = random.randint(2, 5)
nums = [str(random.randint(1, 100)) for _ in range(num_operands)]
func = random.choice(["sin", "cos", "tan"])
expr = nums[0]
for n in nums[1:]:
expr += " " + random.choice(ops) + " " + n
return f"{func}({expr})"