Translation optimized index.md (#21140)

improved translation in function description. translated example description.
This commit is contained in:
zd6
2018-12-21 15:17:45 -06:00
committed by Jingyi Ding
parent 1d37edb8ba
commit 27c78c9dfc

View File

@ -2,7 +2,7 @@
title: Python Max Function
localeTitle: Python Max函数
---
`max()`是Python 3中的内置函数。它返回可迭代中的最大项或两个或多个参数中的最大项。
`max()`是Python 3中的内置函数。它返回可迭代iterable中的最大项,它也可以返回两个或多个参数中的最大项。
## 参数
@ -17,33 +17,33 @@ max(2, 3)
参数无效:
```
max(2, 'a')
max([1, 2, 3, 'a'])
max([])
max(2, 'a') #参数类型一致
max([1, 2, 3, 'a']) #迭代中有参数不一致
max([]) #空的迭代
```
## 回报价
## 回值
返回iterable中的最大项。如果提供了两个或多个位置参数则返回最大的位置参数。如果iterable为空并且未提供default则引发`ValueError`
## 代码示例
```
print(max(2, 3)) # Returns 3 as 3 is the largest of the two values
print(max(2, 3, 23)) # Returns 23 as 23 is the largest of all the values
print(max(2, 3)) # 返回两个参数中的最大值 3 。
print(max(2, 3, 23)) # 返回三个参数中的最大值 23 。
list1 = [1, 2, 4, 5, 54]
print(max(list1)) # Returns 54 as 54 is the largest value in the list
print(max(list1)) # 返回 list1 (一个迭代变量)中的最大值 54 。
list2 = ['a', 'b', 'c' ]
print(max(list2)) # Returns 'c' as 'c' is the largest in the list because c has ascii value larger then 'a' ,'b'.
print(max(list2)) # 返回c'因为c'是 list2 中ascii值最大的 a'的ascii值是97'b'的ascii值是98而'c'的ascii值是99。
list3 = [1, 2, 'abc', 'xyz']
print(max(list3)) # Gives TypeError as values in the list are of different type
print(max(list3)) # 返回 TypeError 因为 list3 中的变量类型并不一致。
#Fix the TypeError mentioned above first before moving on to next step
#请先将此错误修改再进行后面的编码
list4 = []
print(max(list4)) # Gives ValueError as the argument is empty
print(max(list4)) # 返回 ValueError 因为 list4 是空的。
```
![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":火箭:") [运行代码](https://repl.it/CVok)