Answer to Question #265910 in Python for sivakrishna

Question #265910

write a program to print the numbers in the increasing order along with their frequency.


1
Expert's answer
2021-11-14T17:02:43-0500
#Initialize array   
arr = [5, 2, 8, 7, 1];   
temp = 0;  
   
#Displaying elements of original array  
print("Elements of original array: ");  
for i in range(0, len(arr)):  
    print(arr[i], end=" ");  
   
#Sort the array in ascending order  
for i in range(0, len(arr)):  
    for j in range(i+1, len(arr)):  
        if(arr[i] > arr[j]):  
            temp = arr[i];  
            arr[i] = arr[j];  
            arr[j] = temp;  
   
print();  
   
#Displaying elements of the array after sorting  
  
print("Elements of array sorted in ascending order: ");  
for i in range(0, len(arr)):  
    print(arr[i], end=" ");  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS