欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

编程实现对一个元素全为数字的列表,求最大值、最小值(回炉笔记)

程序员文章站 2023-01-12 13:20:34
__author__ = 'zht' #!/usr/bin/env python # -*- coding: utf-8 -*- ''' #努力学习每一天 ''' import operator #方法1 a = [1,2,3,4,5,6,7,11,10,9,] i = 1 b = a[0] whi... ......
__author__ = 'zht'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
#努力学习每一天
'''
import operator

#方法1
a = [1,2,3,4,5,6,7,11,10,9,]
i = 1
b = a[0]

while i <= len(a):
    for k in a:
        if b >= k:
            pass
        else:
            b = k
    i +=1
print(b)

#方法2
res = max(a)
print(res)
res = min(a)
print(res)