Safety-first Python scientific calculator with AST evaluation
PyCalculator
PyCalculator is a modern desktop scientific calculator engineered in Python and Tkinter, designed with security and precision at its core. Unlike basic calculator scripts that rely on dangerous built-in eval() functions, PyCalculator implements a secure Abstract Syntax Tree (AST) parser and evaluator with an explicit whitelist of allowed mathematical operations, constants, and functions. The interface features a clean, responsive grid layout with full keyboard input support, degree-based trigonometric calculations (sin, cos, tan), exponentiation (^ → **), square root, logarithms, and automated Pytest test validation integrated with GitHub Actions CI.

Problem
Many Python calculator tutorials and lightweight desktop utilities execute user input directly through eval(), introducing severe code execution vulnerabilities and unpredictable error handling.
Solution
A robust AST-based safe evaluation engine with an explicit syntax whitelist, degree-to-radian trigonometric normalization, responsive Tkinter layout, and automated CI unit testing.
Outcome
A polished, secure desktop utility showcasing safe Python expression parsing, Tkinter GUI development, mathematical computing precision, and automated testing pipelines.
Standout Features
- Safe expression evaluation powered by Python Abstract Syntax Tree (AST) parser
- Zero raw eval() usage, mitigating arbitrary code execution risks completely
- Degree-based trigonometric calculations (sin, cos, tan), power (^), sqrt, and modulo
- Responsive Tkinter grid GUI with full keyboard input binding and error recovery
Stack & Signals
- Python 3.10+
- Tkinter
- AST Engine
- Math
- Pytest
- GitHub Actions CI
Canonical destination