Skip to content

Commit 6a6ff0e

Browse files
authored
bugfix: avoid use built-in function sum as variable (#45)
1 parent 6647c9d commit 6a6ff0e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/arithmetic-operation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ num1 = 10
6464
num2 = 5
6565

6666
# 1. Addition
67-
sum = num1 + num2
68-
print("Sum:", sum)
67+
sum_val = num1 + num2
68+
print("Sum:", sum_val)
6969

7070
# 2. Subtraction
7171
difference = num1 - num2
@@ -98,6 +98,7 @@ print("Updated num2 after decrement:", num2)
9898

9999
### Code Highlight
100100
- The syntax for addition, subtraction, multiplication, division, remainder, and exponentiation in Python is the same as in JavaScript.
101+
- sum is the [Built-in Function](https://docs.python.org/3/library/functions.html?highlight=sum#sum) in Python, it is important to avoid using it.
101102
- Python does not have the `++` and `--` operators. Instead, `+=` and `-=` are used to increment or decrement variables.
102103

103104
### Difference Quick View

i18n/zh-cn/docusaurus-plugin-content-docs/current/arithmetic-operation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ num1 = 10
6464
num2 = 5
6565

6666
# 1. 相加
67-
sum = num1 + num2
68-
print("和:", sum)
67+
sum_val = num1 + num2
68+
print("和:", sum_val)
6969

7070
# 2. 相减
7171
difference = num1 - num2
@@ -98,6 +98,7 @@ print("自减后的 num2:", num2)
9898

9999
### 代码解读
100100
- Python 的加、减、乘、除、取余、指数运算语法与 JavaScript 一致。
101+
- sum 在Python中是 [内置函数](https://docs.python.org/3/library/functions.html?highlight=sum#sum),在编写代码时应避免使用。
101102
- Python 中没有 `++``--` 运算符,需要使用 `+=``-=` 对变量进行自增或自减。
102103

103104
### 差异速览

0 commit comments

Comments
 (0)