Skip to content

Commit

Permalink
bugfix: avoid use built-in function sum as variable (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangdeyu authored Jan 2, 2024
1 parent 6647c9d commit 6a6ff0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/arithmetic-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ num1 = 10
num2 = 5

# 1. Addition
sum = num1 + num2
print("Sum:", sum)
sum_val = num1 + num2
print("Sum:", sum_val)

# 2. Subtraction
difference = num1 - num2
Expand Down Expand Up @@ -98,6 +98,7 @@ print("Updated num2 after decrement:", num2)

### Code Highlight
- The syntax for addition, subtraction, multiplication, division, remainder, and exponentiation in Python is the same as in JavaScript.
- 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.
- Python does not have the `++` and `--` operators. Instead, `+=` and `-=` are used to increment or decrement variables.

### Difference Quick View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ num1 = 10
num2 = 5

# 1. 相加
sum = num1 + num2
print("和:", sum)
sum_val = num1 + num2
print("和:", sum_val)

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

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

### 差异速览
Expand Down

0 comments on commit 6a6ff0e

Please sign in to comment.