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.
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.
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.
What about max()
highest = max(1, 2, 3) # or max([1, 2, 3]) for lists
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With