How to find the maximum value of a set of numbers in python?

coldplay.xixi
Release: 2020-06-29 17:07:54
Original
16070 people have browsed it

How to find the maximum value of a set of numbers in python?

#How to find the maximum value of a set of numbers in python?

Python method to find the maximum value of a set of numbers:

First define a set of numbers and variable a, and assign [a=list(0)] ; Then use range loop to query. If the number is greater than [list=(0)], then pass the value to a and output it.

def max2(list):
    a = list[0]
    for prime in range (1,len(list)):
        if list[prime] > list[0]:
         a = list[prime]
    return a
print(max2([1,5,2,3,6,8,10,15]))
Copy after login

Recommended tutorial: "python video tutorial"

The above is the detailed content of How to find the maximum value of a set of numbers in python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!