[Python] [5] [demo experimental practice examples] [sort]

Original title:

Enter three integers x, y, z, please these three numbers small to large outputs.

 

My solution:

# ! / Usr / bin / Python 
# encoding = UTF. 8- 
# - * - Coding: UTF-. 8 - * - 

# input three integers x, y, z, please these three numbers small to large outputs. 
= L [] 
l.append (int (INPUT ( " First NUM: \ n- " ))) 
l.append (int (INPUT ( " SECOND NUM: \ n- " ))) 
l.append (int (INPUT ( " THIRD NUM: \ n- " ))) 

" "" 
L [0] = int (INPUT ( "First NUM: \ n-")) 
L [. 1] = int (INPUT ( "SECOND NUM: \ n-")) 
L [2 ] = int (INPUT ( "THIRD NUM: \ n-")) 
"" " 

IF L [0]> L [. 1 ]: 
    L [0], l[1] > l[2]:
        l[1],l[2] = l[2],l[1]
        if l[0] > l[2]:
            l[0],l[2] = l[2],l[0]

            
for i in range(len(l)):
    print(l[i],end = " ")
    if i == len(l)-1:
        break
    else:
        print("",end = " < ")
    

 

Output results:

C:\Python30_demo>python 020demo.py
first num:
6
second num:
4
third num:
5
4  < 5  < 6

 

 

 

Original answer given by:

 

 

 

 

-------- (I am dividing line) --------

reference:

1. RUNOOB.COM  : https://www.runoob.com/python/python-exercise-example5.html

 

Remarks:

Initial modified: September 23, 2019 23:29:02

 

Environment: Windows 7 / Python 3.7.2

 

Guess you like

Origin www.cnblogs.com/kaixin2018/p/11575658.html