Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the greatest number in a list of numbers

Is there any easy way or function to determine the greatest number in a python list? I could just code it, as I only have three numbers, however it would make the code a lot less redundant if I could tell the greatest with a built in function or something.

like image 547
Chris Foster Avatar asked Jun 22 '10 03:06

Chris Foster


People also ask

How do you find the maximum number of a number?

To find the maximum number, the fractional numbers are converted to decimals and compared through the modulus operation. The first number is |7/5| = 7/5 = 1.4, the second |-3/2| = 3/2 = 1.5, and the third |-8/3| = 8/3 ≈ 2.67. From these values, we see that the maximal value is 2.67, which corresponds to -8/3 fraction.

How can the largest number in a list of twenty numbers be found?

Expert-verified answer Now, the number which occur at the last is the required largest number. All the numbers in the list are arranged in the descending order such that the largest number comes at the beginning and so on.


1 Answers

What about max()

highest = max(1, 2, 3)  # or max([1, 2, 3]) for lists 
like image 123
Jubal Avatar answered Oct 25 '22 06:10

Jubal