Skip to content

About

MathQuiz API provides simple endpoints that generate a random arithmetic problem and its solution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

MathQuiz API

MathQuiz API provides simple endpoints that generate a random arithmetic problem and its solution.

Requirements

  • Python 3.8+
  • FastAPI (recommended install: fastapi[standard])

Install dependencies:

pip install "fastapi[standard]"

Run

Start the development server from the project folder:

uvicorn main:app --reload

Open the interactive API docs at: http://127.0.0.1:8000/docs

Endpoints

All endpoints accept these optional query parameters:

  • min (float) — lower bound (default 0.0)
  • max (float) — upper bound (default 100.0)
  • decimals (bool) — whether to generate decimal numbers (default false)

Available endpoints (GET):

  • /add — addition
  • /subtract — subtraction
  • /multiply — multiplication
  • /divide — division (division avoids zero divisors; invalid ranges return 400)

Example requests:

# integer addition between 10 and 50
curl "http://127.0.0.1:8000/add?min=10&max=50&decimals=false"

# decimal division between 1 and 10
curl "http://127.0.0.1:8000/divide?min=1&max=10&decimals=true"

Response format

Responses are JSON objects with these fields:

  • task: the problem as a string (e.g. "40 + 50" or "3.14 / 2.00")
  • solution: the evaluated result (integers for integer mode, rounded floats when decimals=true)

Example response (integers):

{
  "task": "40 + 50",
  "solution": 90
}

Example response (decimals):

{
  "task": "3.14 / 2.00",
  "solution": 1.57
}

About

MathQuiz API provides simple endpoints that generate a random arithmetic problem and its solution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages