A powerful dual-interface calculator that generates and solves hundreds of math problems instantly!
Terminal Interface • Web Application • Features • Installation
Welcome to the AI Calculator – your ultimate tool for generating, solving, and analyzing batches of arithmetic problems! Whether you're a teacher creating practice worksheets, a student testing your skills, or a developer exploring math problem generation, this project has you covered.
- 🚀 Lightning Fast: Generate and solve 100+ problems in milliseconds
- 🌍 Multi-Language: Supports English, Arabic, Hindi, French, and Spanish
- 💻 Dual Interface: Choose between Terminal (TUI) or modern Web UI
- ⚙️ Fully Customizable: Adjust difficulty, operations, and problem count
- 📊 Rich Statistics: Get instant insights with averages, distributions, and more
- 💾 Export Options: Save results as JSON or CSV for further analysis
| Feature | Description |
|---|---|
| Batch Generation | Create up to 1000 problems with a single click |
| Smart Validation | Automatic prevention of division by zero |
| Difficulty Levels | Easy, Medium, and Hard modes with tailored ranges |
| Operation Filtering | Select specific operations (+, -, ×, ÷) |
| Real-time Stats | Average, min, max, and operator distribution |
| Export Functionality | Download results in JSON or CSV format |
The application speaks your language! Currently supported:
- 🇺🇸 English (en)
- 🇸🇦 Arabic (ar) - Right-to-left support
- 🇮🇳 Hindi (hi) - Devanagari script
- 🇫🇷 French (fr)
- 🇪🇸 Spanish (es)
| Level | Addition/Subtraction | Multiplication | Division |
|---|---|---|---|
| Easy | 1-20 | 1-10 | 2-6 |
| Medium | 10-100 | 2-20 | 2-12 |
| Hard | 50-500 | 10-50 | 5-20 |
A classic TUI experience using npyscreen for terminal enthusiasts.
# Install dependencies
pip install npyscreen
# Run the application
python main.py| Key | Action |
|---|---|
Ctrl+G |
Generate problems |
Ctrl+C |
Clear results |
Ctrl+E |
Export to file |
Ctrl+Q |
Quit application |
A modern, responsive web interface with beautiful UI and real-time updates.
# Navigate to webapp directory
cd webapp
# Install Flask (if not already installed)
pip install flask
# Start the server
python app.pyThen open your browser and navigate to http://localhost:5000
- 🎨 Modern Design: Gradient backgrounds and smooth animations
- 📱 Responsive: Works on desktop, tablet, and mobile
- ⚡ Real-time Updates: Instant problem generation without page reload
- 🌙 Language Switching: Change languages on the fly
- 📊 Live Statistics: Dynamic charts and metrics
- 💾 One-Click Export: Download JSON or CSV instantly
| Endpoint | Method | Description |
|---|---|---|
/api/generate |
POST | Generate math problems |
/api/clear |
POST | Clear current session |
/api/export/json |
GET | Export as JSON |
/api/export/csv |
GET | Export as CSV |
/api/stats |
GET | Get statistics |
/api/translations/<lang> |
GET | Get translations |
# Generate 50 easy problems with addition only
curl -X POST http://localhost:5000/api/generate \
-H "Content-Type: application/json" \
-d '{"count": 50, "difficulty": "easy", "operations": ["+"]}'
# Get statistics
curl http://localhost:5000/api/stats
# Get French translations
curl http://localhost:5000/api/translations/fr# For Terminal Interface
pip install npyscreen
# For Web Application
pip install flask# Install poetry if not already installed
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Run terminal interface
poetry run python main.py
# Run web application
cd webapp
poetry run python app.py/workspace/
├── main.py # Terminal interface application
├── README.md # This documentation
├── pyproject.toml # Poetry configuration
├── poetry.lock # Poetry lock file
└── webapp/ # Web application
├── app.py # Flask backend
├── templates/
│ └── index.html # Main HTML template
└── static/
├── css/
│ └── style.css # Stylesheets
└── js/
└── app.js # Frontend JavaScript
All components have been thoroughly tested and verified:
- ✓ Problem generation (all difficulties)
- ✓ Operation filtering
- ✓ Division by zero prevention
- ✓ Export functionality (JSON & CSV)
- ✓ Multi-language translations
- ✓ Statistics calculation
- ✓ Generate endpoint
- ✓ Clear endpoint
- ✓ Export endpoints (JSON & CSV)
- ✓ Statistics endpoint
- ✓ Translations endpoint (5 languages)
- ✓ Custom parameters handling
Run tests manually:
# Test TUI backend
python -c "from main import BatchGenerator; print('TUI OK')"
# Test Web API
cd webapp && python -c "from app import app; print('Web OK')"from main import BatchGenerator, Difficulty, ExportManager, Summary
# Create generator with medium difficulty
generator = BatchGenerator(Difficulty.MEDIUM)
# Generate 100 problems
problems = generator.generate(count=100)
# Filter to only addition and subtraction
problems = generator.generate(count=50, allowed_operations=['+', '-'])
# Export to JSON
exporter = ExportManager()
exporter.export_to_json(problems, Summary(problems), 'results.json')
# Export to CSV
exporter.export_to_csv(problems, 'results.csv')// Generate problems
fetch('/api/generate', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
count: 100,
difficulty: 'medium',
operations: ['+', '-', '×', '÷'],
language: 'en'
})
})
.then(res => res.json())
.then(data => console.log(data.problems));
// Get statistics
fetch('/api/stats')
.then(res => res.json())
.then(stats => console.log(`Average: ${stats.average}`));
// Change language
fetch('/api/translations/es')
.then(res => res.json())
.then(data => updateUI(data.translations));- Range: 1 - 1000
- Default: 100
- Recommended: 50-200 for best performance
Available operators:
+Addition-Subtraction×Multiplication÷Division
# Easy - Perfect for beginners
difficulty = Difficulty.EASY
# Medium - Standard level
difficulty = Difficulty.MEDIUM
# Hard - Challenge mode
difficulty = Difficulty.HARDWe welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guidelines
- Add type hints to all functions
- Include docstrings for public methods
- Write tests for new features
- Update documentation accordingly
This project is licensed under the MIT License.
- Built with ❤️ using Python
- Terminal UI powered by npyscreen
- Web framework by Flask
- Inspired by the need for efficient math problem generation
Made with Python 🐍 | Supporting 5 Languages 🌍 | Dual Interface 💻
⭐ Star this repo if you find it useful! ⭐