# Import the modules
import random
import time
import sympy
from sympy.parsing.sympy_parser import parse_expr
from sympy.solvers import solve
from sympy import Symbol
import winsound
# Define the alarm sound
sound = "alarm.wav"
# Define the difficulty level of the calculus problems
difficulty = 3 # 1: easy, 2: medium, 3: hard
# Define the number of problems to solve
num_problems = 3
# Define the time limit for each problem in seconds
time_limit = 30
# Define the score for each correct answer
score = 10
# Define the total score
total_score = 0
# Define the symbols for the calculus problems
x = Symbol('x')
y = Symbol('y')
z = Symbol('z')
# Define the list of possible calculus problems
problems = [
# Easy problems
[
("Find the derivative of f(x) = x^2 + 3x - 5", "2*x + 3"),
("Find the derivative of f(x) = sin(x) + cos(x)", "cos(x) - sin(x)"),
("Find the derivative of f(x) = e^x + ln(x)", "e^x + 1/x"),
("Find the integral of f(x) = x^2 + 3x - 5", "x^3/3 + 3*x^2/2 - 5*x"),
("Find the integral of f(x) = sin(x) + cos(x)", "-cos(x) + sin(x)"),
("Find the integral of f(x) = e^x + ln(x)", "e^x + x*ln(x) - x")
],
# Medium problems
[
("Find the derivative of f(x) = x^3 * sin(x)", "3*x^2 * sin(x) + x^3 * cos(x)"),
("Find the derivative of f(x) = ln(x^2 + 1)", "2*x / (x^2 + 1)"),
("Find the derivative of f(x) = e^(x^2)", "2*x * e^(x^2)"),
("Find the integral of f(x) = x^3 * sin(x)", "-x^3 * cos(x) + 3*x^2 * sin(x) - 6*x * cos(x) + 6 * sin(x)"),
("Find the integral of f(x) = ln(x^2 + 1)", "x * ln(x^2 + 1) - 2 * atan(x)"),
("Find the integral of f(x) = e^(x^2)", "sqrt(pi) * erf(x) / 2")
],
# Hard problems
[
("Find the derivative of f(x,y) = x^2 * y^3 + sin(x*y)", "2*x * y^3 + x^2 * 3*y^2 + y * cos(x*y)"),
("Find the derivative of f(x,y) = ln(x^2 + y^2)", "2*x / (x^2 + y^2)"),
("Find the derivative of f(x,y) = e^(x*y)", "y * e^(x*y)"),
("Find the integral of f(x,y) = x^2 * y^3 + sin(x*y)", "x^3 * y^3 / 3 - cos(x*y)"),
("Find the integral of f(x,y) = ln(x^2 + y^2)", "x * y * ln(x^2 + y^2) - 2 * x * y + 2 * atan(y/x)"),
("Find the integral of f(x,y) = e^(x*y)", "e^(x*y) / (x + y)")
]
]
# Define a function to check the answer
def check_answer(problem, answer):
# Parse the problem and the answer into sympy expressions
problem = parse_expr(problem)
answer = parse_expr(answer)
# Check if the problem is a derivative or an integral
if problem.has(sympy.Derivative):
# Solve the problem for the derivative
solution = solve(problem, sympy.Derivative)
# Check if the answer matches the solution
return answer == solution[0]
elif problem.has(sympy.Integral):
# Solve the