Advertisement
aed1oN

Untitled

Oct 20th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. # reading from input
  2. input_data = []
  3. for i in range(0, 10):
  4. input_data.append(int(input("Enter your number: ")))
  5.  
  6. # sorting
  7. for i in range(0, len(input_data)):
  8. key = input_data[i]
  9. j = i - 1
  10. while j >= 0 and key < input_data[j]:
  11. input_data[j+1] = input_data[j]
  12. j = j - 1
  13. input_data[j+1] = key
  14. print("Numbers you entered are: ", input_data)
  15.  
  16. # numbers without repetition
  17. without_rep_list = []
  18. for i in range(0, len(input_data)-1):
  19. for j in range(i+1, len(input_data)):
  20. if input_data[i] != input_data[j]:
  21. without_rep_list.append(input_data[i])
  22. break
  23. for i in range(0, len(without_rep_list)):
  24. if input_data[-1] != without_rep_list[i]:
  25. f = 1
  26. else:
  27. f = 0
  28. break
  29. if f == 1:
  30. without_rep_list.append(input_data[-1])
  31.  
  32. # counting repeting elements
  33. previous = input_data[0]
  34. counter = 0
  35. counter_list = []
  36. for i in range(0, len(input_data)):
  37. if previous == input_data[i]:
  38. counter = counter + 1
  39. else:
  40. print(previous, " : ", counter)
  41. counter_list.append(counter)
  42. previous = input_data[i]
  43. counter = 1
  44.  
  45. counter_list.append(counter)
  46. print(previous, " : ", counter)
  47. maximum = 0
  48. for i in range(0, len(counter_list)):
  49. if counter_list[i] > maximum:
  50. maximum = counter_list[i]
  51. j = i
  52. print("Most common element is: ", without_rep_list[j])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement