Calculator Skill
Perform accurate mathematical calculations using the calc.py script.
Usage
Run calculations directly with Python:
CODEBLOCK0
Supported Operations
Basic Arithmetic
- -
+ Addition: 2 + 3 → 5 - INLINECODE3 Subtraction:
10 - 4 → 6 - INLINECODE5 Multiplication:
6 * 7 → 42 - INLINECODE7 Division:
15 / 3 → 5
Powers & Roots
- -
^ or ** Power: 2^10 → 1024 - INLINECODE12 Square root:
sqrt(16) → 4
Percentages
- -
100 * 15% → 15 (15% of 100) - INLINECODE15 → 55 (add 10%)
Trigonometry (radians)
- -
sin(pi/2) → 1 - INLINECODE17 → -1
- INLINECODE18 → 1
Logarithms
- -
log(100) → 2 (base 10) - INLINECODE20 → 1 (natural log)
Constants
- -
pi → 3.141592653589793 - INLINECODE22 → 2.718281828459045
Other Functions
- -
abs(-5) → 5 - INLINECODE24 → 4
- INLINECODE25 → 3
- INLINECODE26 → 4
- INLINECODE27 → 256
Examples
CODEBLOCK1
Notes
- - Implicit multiplication supported:
2(3) = INLINECODE29 - Use parentheses for grouping
- Float results are rounded to 10 decimal places to avoid precision issues
计算器技能
使用calc.py脚本执行精确的数学计算。
使用方法
直接通过Python运行计算:
bash
python3 <技能路径>/scripts/calc.py <表达式>
支持的操作
基础算术运算
- - + 加法:2 + 3 → 5
- - 减法:10 - 4 → 6
- 乘法:6 7 → 42
- / 除法:15 / 3 → 5
幂与根运算
- - ^ 或 幂运算:2^10 → 1024
- sqrt() 平方根:sqrt(16) → 4
百分比计算
- - 100 15% → 15(100的15%)
- 50 + 50 10% → 55(增加10%)
三角函数(弧度制)
- - sin(pi/2) → 1
- cos(pi) → -1
- tan(pi/4) → 1
对数运算
- - log(100) → 2(以10为底)
- ln(e) → 1(自然对数)
常量
- - pi → 3.141592653589793
- e → 2.718281828459045
其他函数
- - abs(-5) → 5
- round(3.7) → 4
- floor(3.9) → 3
- ceil(3.1) → 4
- pow(2, 8) → 256
示例
bash
python3 scripts/calc.py 2 + 3 * 4 # 14
python3 scripts/calc.py (2 + 3) * 4 # 20
python3 scripts/calc.py sqrt(144) # 12
python3 scripts/calc.py 2^8 # 256
python3 scripts/calc.py 1000 * 5% # 50
python3 scripts/calc.py sin(0) # 0
python3 scripts/calc.py log(1000) # 3
注意事项
- - 支持隐式乘法:2(3) = 2*3
- 使用括号进行分组
- 浮点数结果四舍五入到10位小数以避免精度问题