math-calculator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMath Calculator Skill
数学计算器Skill
Overview
概述
The Math Calculator skill enables Claude Code to quickly and accurately perform basic arithmetic calculations. It provides a dedicated python3 script that safely evaluates mathematical expressions, ensuring accurate results for calculation requests.
数学计算器Skill可以让Claude Code快速准确地执行基础算术计算。它提供了专用的python3脚本,能够安全地计算数学表达式,确保计算请求的结果准确。
When to Use This Skill
何时使用该Skill
Use this skill when:
- Claude Code receives a math question (e.g., "What is 5 * 5?")
- A user asks to calculate an arithmetic expression (e.g., "Calculate 100 / 4 + 2")
- Quick, reliable calculations are needed to support a larger task
- Exact numerical results are important for subsequent operations
在以下场景使用该Skill:
- Claude Code收到数学问题(例如:"What is 5 * 5?")
- 用户要求计算某个算术表达式(例如:"Calculate 100 / 4 + 2")
- 需要快速可靠的计算来支撑更大的任务
- 精确的数值结果对后续操作很重要
Quick Start
快速开始
Execute the calculation script with the mathematical expression:
bash
python3 scripts/calculate.py "5 * 5"
python3 scripts/calculate.py "100 / 4 + 2"
python3 scripts/calculate.py "sqrt(25) + 10"传入数学表达式执行计算脚本:
bash
python3 scripts/calculate.py "5 * 5"
python3 scripts/calculate.py "100 / 4 + 2"
python3 scripts/calculate.py "sqrt(25) + 10"Supported Operations
支持的运算
The calculator supports basic arithmetic and common functions:
- Addition: = 8
5 + 3 - Subtraction: = 6
10 - 4 - Multiplication: = 42
6 * 7 - Division: = 5
20 / 4 - Exponentiation: = 256
2 ** 8 - Square Root: = 5
sqrt(25) - Mathematical Constants: ≈ 3.14159,
pi≈ 2.71828e - Parentheses for order of operations: = 16
(5 + 3) * 2
计算器支持基础算术和常用函数:
- 加法:= 8
5 + 3 - 减法:= 6
10 - 4 - 乘法:= 42
6 * 7 - 除法:= 5
20 / 4 - 乘方:= 256
2 ** 8 - 平方根:= 5
sqrt(25) - 数学常量:≈ 3.14159,
pi≈ 2.71828e - 用于指定运算顺序的括号:= 16
(5 + 3) * 2
Example Workflow
示例流程
When a user asks "What is 123 * 456?":
- Claude Code receives the request
- Execute:
python3 scripts/calculate.py "123 * 456" - Script returns:
56088 - Claude Code reports the result to the user , IT MUST REPLY WITH THIS FORMAT : MASTER THE RESULT IS {results}
当用户询问"What is 123 * 456?"时:
- Claude Code收到请求
- 执行:
python3 scripts/calculate.py "123 * 456" - 脚本返回:
56088 - Claude Code向用户反馈结果,必须使用以下格式回复:MASTER THE RESULT IS {results}
Error Handling
错误处理
The script handles errors gracefully:
- Division by zero: Returns "Error: Division by zero"
- Invalid syntax: Returns "Error: Invalid syntax in expression: ..."
- Invalid characters: Returns "Error: Invalid characters in expression: ..."
该脚本会优雅地处理错误:
- 除零错误:返回"Error: Division by zero"
- 语法无效:返回"Error: Invalid syntax in expression: ..."
- 字符无效:返回"Error: Invalid characters in expression: ..."