In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to obtain the maximum function in Python. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Code implementation
Print (max (1,2))
Print (max ('averse,' b'))
# can also be used for lists and tuples
Print (max ([1,2]))
Print (max ((1,2)
# more instances
Print ("80,100,1000 maximum is:"
Max (80,100,1000)
Print ("- 20,100,400 maximum value is:"
Max (- 20,100,400)
The maximum value of print ("- 80,-20,-10) is:"
Max (- 80,-20,-10))
Print ("0,100,400 maximum value is:"
Max (0,100,400)
The result of running the code:
Enter a number: 54
54 is an even number.
Program analysis
The max function is mainly used in the program:
The max () method returns the maximum value of a given parameter, which can be a sequence.
The following is the syntax of the max () method:
Max (x, y, z,.... ) parameters
X-numeric expression.
Y-numeric expression.
Z-numeric expression.
Return value: returns the maximum value of a given parameter.
The following is an extension:
>
> type (a) # type is a string
> max (a) # max returned the maximum value
'4'
> a = [1, 2, 3, 4]
> type (a) # Type is a list
The max (a) # max function also returns the maximum value
four
> > >
> > >
> a = [(1jin2), (2p3), (3pd4)] # suppose there are tuple elements in the list
> max (a) # according to the order of the first element in the tuple of the element, the output maximum value (if the first element is the same, the second element is compared, the output maximum value) is inferred to be sorted by ascii code
(3, 4)
The experiment speculates that it is sorted according to ascii code. Comparing the values of an and A, we can get a > A, because in ascii code, an is smaller than A.
> > max (a)
('asides, 1)
> a = [(1, 2), (2, 3), (3, 1)]
The elements in the list are all composed of tuples, tuples are all composed of numbers, and the maximum value is output.
> > max (a)
(3, 1)
> a = [(1rem 3), (2je 2), (3je 1), (3je 1)]
> > max (a)
(3, 1)
> a = [(1rem 3), (2je 2), (3je 1), (3je 2)]
> > max (a)
(3, 2)
> > >
> a = [(1pr 3), (2je 2), (3je 1), (3je mnemb'), ('afeire1)]
> > max (a)
('asides, 1)
> a = [(1pr 3), (2je 2), (3je 1), (3je dint b'), ('a feather dagger 1), ('fame dint 3)]
> > max (a)
('favored, 3)
> > >
The maximum value in the comparison dictionary will output the maximum key.
> > max (a)
four
On how to get the maximum function in Python to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.