Advertisement
pongfactory

Python_min_max_sort

Feb 27th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. d = [1,3,2,5,9,8,4,5,6]
  2.  
  3. max = d[0]
  4. min = d[0]
  5.  
  6. for e in d[1:]:
  7.     if e > max:
  8.         max = e
  9.  
  10. for e in d[1:]:
  11.     if e < min:
  12.         min = e
  13.  
  14. for all in range(len(d)-1,0,-1):
  15.     for i in range(0,all,1):
  16.         if d[i] > d[i+1]:
  17.             temp = d[i]
  18.             d[i] = d[i+1]
  19.             d[i+1] = temp
  20.  
  21.  
  22. print(max)
  23. print(min)
  24. print("bubble sort from min to max = ",d)
  25.  
  26.  
  27. #in_txt  = input("Enter digits : ")
  28. in_txt = "2845"
  29. out_txt = ""
  30. arabic_number = "0123456789"
  31. thai_number   = "๐๑๒๓๔๕๖๗๘๙"
  32. for a in in_txt :
  33.     k = int(a)
  34.     if k < 0 :
  35.         out_txt += "Negative"
  36.     else :
  37.         out_txt += thai_number[int(a)]
  38. print(out_txt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement