简体   繁体   English

Python:最大和最小函数

[英]Python: max & min functions

I really don't understand the max or min functions, the meaning of them.我真的不明白 max 或 min 函数,它们的含义。 For instance, when i write these in the notepad++, in the output i see a letter of the word.例如,当我在记事本++中写下这些时,在输出中我看到了一个单词的字母。 And i can't understand it.我无法理解。 Why only this letter, not another letters of this word?为什么只有这个字母,而不是这个词的其他字母? Please, help me on this way.请帮我走这条路。 Thanks谢谢

In the Notepad++在记事本++中

  • x = max ("Hello Home") x = max ("Hello Home")
  • print x打印 x
  • y = min ("World") y = 分钟(“世界”)
  • print y打印 y

In the Output在输出中

  • o

  • W

输入输出图像

As per the ASCII table根据 ASCII 表

  • Capital letters points to decimal 65 to 90 (65-90 → AZ )大写字母指向十进制 65 到 90(65-90 → AZ)
  • Small letters points to decimal 97-122 (97-122 → az)小写字母指向十进制 97-122 (97-122 → az)

so, max value = o (decimal 111) min value = W (decimal 87)所以,最大值 = o(十进制 111) 最小值 = W(十进制 87)

ASCII table for your reference ASCII 表供您参考

ASCII 表

To find out why, you can map ord over the strings:要找出原因,您可以map ord map到字符串上:

>>> list(map(ord, "Hello Home"))
[72, 101, 108, 108, 111, 32, 72, 111, 109, 101]

The highest number in there is 111, which corresponds to "o" (the ASCII value of "o" is 111).其中最大的数字是 111,对应于“o”(“o”的 ASCII 值是 111)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM