python-内建函数-最大值、最小值和求和函数

1. python-最大值、最小值和求和函数

  • min() 返回可迭代对象中最小的元素
  • max() 返回可迭代对象中最大的元素
  • sum() 对可迭代对象求和

2. 案例

  • 最大值

    #!/usr/bin/env python3
    # _*_ coding: utf-8 _*_
    # Author:shichao
    # File: .py
    
    s = [1,2,3,4,5,6]
    print(s)
    
    
    # 求最大值
    print(max(s))
    
  • 最小值

    #!/usr/bin/env python3
    # _*_ coding: utf-8 _*_
    # Author:shichao
    # File: .py
    
    s = [1,2,3,4,5,6]
    print(s)
    
    # 最小值
    print(min(s))
    
    
  • 求和函数

    #!/usr/bin/env python3
    # _*_ coding: utf-8 _*_
    # Author:shichao
    # File: .py
    
    s = [1,2,3,4,5,6]
    print(s)
    
    
    # 求和
    print(sum(s))
    
posted @ 2023-01-06 10:09  七月流星雨  阅读(182)  评论(0编辑  收藏  举报