Python exercise question 005: three numbers are output in ascending order and python005
[Python exercise question 005]Input three integers x, y, and z. Please output these three numbers from small to large.
-----------------------------------------------------------------------
It should be easier to think about this question: it is nothing more than getting three numbers first, and then compare the size, output in order. However, you may encounter a problem during code writing: you may need to specify multiple delimiters (English commas, Chinese commas, and spaces) for inputting unspecified delimiters during input, but str. split () only accepts one separator.
After searching the Internet, we found that we could use regular expressions to solve this problem, so we had the import re line. The Code is as follows:
Import rex, y, z = re. split (', |, |', input ('enter three numbers, separated by commas or spaces:') x, y, z = int (x ), int (y), int (z) maxNo = max (x, y, z) minNo = min (x, y, z) print (maxNo, x + y + z-maxNo-minNo, minNo)
I have long known that regular expressions are very powerful, but it is too difficult to touch them ...... You must study this part in the future!
++
Source: getting started with programming languages: 100 typical examples [Python]