Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # reading from input
- input_data = []
- for i in range(0, 10):
- input_data.append(int(input("Enter your number: ")))
- # sorting
- for i in range(0, len(input_data)):
- key = input_data[i]
- j = i - 1
- while j >= 0 and key < input_data[j]:
- input_data[j+1] = input_data[j]
- j = j - 1
- input_data[j+1] = key
- print("Numbers you entered are: ", input_data)
- # numbers without repetition
- without_rep_list = []
- for i in range(0, len(input_data)-1):
- for j in range(i+1, len(input_data)):
- if input_data[i] != input_data[j]:
- without_rep_list.append(input_data[i])
- break
- for i in range(0, len(without_rep_list)):
- if input_data[-1] != without_rep_list[i]:
- f = 1
- else:
- f = 0
- break
- if f == 1:
- without_rep_list.append(input_data[-1])
- # counting repeting elements
- previous = input_data[0]
- counter = 0
- counter_list = []
- for i in range(0, len(input_data)):
- if previous == input_data[i]:
- counter = counter + 1
- else:
- print(previous, " : ", counter)
- counter_list.append(counter)
- previous = input_data[i]
- counter = 1
- counter_list.append(counter)
- print(previous, " : ", counter)
- maximum = 0
- for i in range(0, len(counter_list)):
- if counter_list[i] > maximum:
- maximum = counter_list[i]
- j = i
- print("Most common element is: ", without_rep_list[j])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement