{"id":24792726,"url":"https://github.com/misaghmomenib/calculator-python","last_synced_at":"2026-04-28T23:02:09.339Z","repository":{"id":259514062,"uuid":"878084755","full_name":"MisaghMomeniB/Calculator-Python","owner":"MisaghMomeniB","description":"A Simple Yet Powerful Python-based Calculator for Performing Basic Arithmetic Operations. Lightweight and User-friendly, Perfect for Quick Calculations or as a Foundation for Building More Advanced Mathematical Tools.","archived":false,"fork":false,"pushed_at":"2025-02-07T08:12:09.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T09:23:03.994Z","etag":null,"topics":["calculator","calculator-application","calculator-python","git","open-source","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MisaghMomeniB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T18:50:47.000Z","updated_at":"2025-02-07T08:12:13.000Z","dependencies_parsed_at":"2024-11-13T16:30:59.069Z","dependency_job_id":"6aa1d798-18be-471c-b610-8c04d9bb4eb4","html_url":"https://github.com/MisaghMomeniB/Calculator-Python","commit_stats":null,"previous_names":["misaghmomenib/calculator-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FCalculator-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FCalculator-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FCalculator-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FCalculator-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MisaghMomeniB","download_url":"https://codeload.github.com/MisaghMomeniB/Calculator-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304873,"owners_count":20593626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculator","calculator-application","calculator-python","git","open-source","python"],"created_at":"2025-01-29T20:54:40.127Z","updated_at":"2026-04-28T23:02:09.333Z","avatar_url":"https://github.com/MisaghMomeniB.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ➕➖➗ Calculator (Python)\r\n\r\nA clean and extensible **command-line calculator** built using Python. Supports mathematical expressions, variables, basic functions, and easy extension—ideal for learning parsing, REPL interfaces, or quick CLI calculations.\r\n\r\n---\r\n\r\n## 📋 Table of Contents\r\n\r\n1. [Overview](#overview)  \r\n2. [Features](#features)  \r\n3. [Requirements](#requirements)  \r\n4. [Installation](#installation)  \r\n5. [Usage Examples](#usage-examples)  \r\n6. [Code Structure](#code-structure)  \r\n7. [Extendability](#extendability)  \r\n8. [Contributing](#contributing)  \r\n9. [License](#license)\r\n\r\n---\r\n\r\n## 💡 Overview\r\n\r\nThis command-line calculator provides interactive evaluation of mathematical expressions, support for variables, and function definitions. It’s implemented with emphasis on modular design, clean parsing, and intuitive user experience—perfect for educational purposes or as a building block in larger tools.\r\n\r\n---\r\n\r\n## ✅ Features\r\n\r\n- ✅ **Evaluate expressions**: `+, -, *, /, **`, parentheses  \r\n- 🧮 Use **variables** (`x = 5`, `y = x * 2`)  \r\n- 🛠️ Define **simple functions**: e.g. `def square(n): return n**2`  \r\n- 🧵 Interactive **REPL loop**: Accepts assignments, expressions, and commands  \r\n- 🗑️ **Session state persistence**: Variables/functions retained throughout session  \r\n- 🔄 Easily **extendable parser** for new operators or functions\r\n\r\n---\r\n\r\n## 🧾 Requirements\r\n\r\n- Python **3.7+**  \r\n- No external dependencies—implemented with `ast`, `math`, and standard libraries\r\n\r\n---\r\n\r\n## ⚙️ Installation\r\n\r\n```bash\r\ngit clone https://github.com/MisaghMomeniB/Calculator-Python.git\r\ncd Calculator-Python\r\n````\r\n\r\n---\r\n\r\n## 🚀 Usage Examples\r\n\r\nStart the REPL:\r\n\r\n```bash\r\npython calculator.py\r\n```\r\n\r\nExample session:\r\n\r\n```\r\n\u003e x = 10\r\n\u003e y = 3 * x + 5\r\n\u003e y\r\n35\r\n\u003e def square(n): return n * n\r\n\u003e square(7)\r\n49\r\n\u003e (x + y) / square(2)\r\n9.0\r\n\u003e quit\r\n```\r\n\r\n---\r\n\r\n## 📁 Code Structure\r\n\r\n```\r\nCalculator-Python/\r\n├── calculator.py     # Main file with parser, evaluator, and REPL\r\n└── README.md         # This file\r\n```\r\n\r\n* Uses the `ast` module for safe expression parsing\r\n* Maintains a symbol table for variables/functions\r\n* Handles errors like division by zero or syntax errors gracefully\r\n* REPL supports built-in commands: `help`, `quit`, etc.\r\n\r\n---\r\n\r\n## ⚙️ Extendability\r\n\r\n* 🌐 Add **math module functions** (`sin`, `cos`, `log`) via symbol table\r\n* ➕ Extend parser with new operators or syntax\r\n* 📦 Package as a module or CLI script with `argparse`\r\n* 🔐 Add **sandbox restrictions** for secure execution\r\n\r\n---\r\n\r\n## 🤝 Contributing\r\n\r\nContributions are welcome! Ideas include:\r\n\r\n* Add built-in **trigonometric functions** (`math.sin`, `math.cos`, etc.)\r\n* Implement **persistent session** (save/load variables)\r\n* Add **unit tests** (e.g., using `pytest`)\r\n* Enhance REPL with **history navigation** (`readline`) or features\r\n\r\nTo contribute:\r\n\r\n1. Fork the repository\r\n2. Create a branch (`feature/...`)\r\n3. Add tests \u0026 comments\r\n4. Submit a detailed Pull Request\r\n\r\n---\r\n\r\n## 📄 License\r\n\r\nReleased under the **MIT License** — see `LICENSE` for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fcalculator-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisaghmomenib%2Fcalculator-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fcalculator-python/lists"}