# Exercise 1 — Sorting # Description: Five numbers are given as input. # Print them in ascending order. # Input Example: 5 2 9 1 7 # Output Example: 1 2 5 7 9 num = [1,5,4,2,3] num.sort() print(num) num = [10,9,6,8,7] result = sorted(num) print(result) print(num) # ------------------------------------------------------------------------------------- # Exercise 2 — Finding the Number of Mismatched Positions # Description: Two lists are provided. # Print the count of positions where the elements are different. # Input Example: 1 2 3 4 # 1 3 2 4 # Output Example: 2 # ----------------------------------------------------------------------------------------- # Exercise 3 — Finding the Misplaced Number # Description: The numbers are almost in ascending order, but exactly one number is in the wrong position. # Compare the original list with the sorted version and print the number of mismatched positions. # Input Example: 2 4 7 7 9 3 # Output Example: 4 # Explanation: Current: 2 4 7 7 9 3 # Sorted: 2 3 4 7 7 9 # Mismatched positions: # Index 1 # Index 2 # Index 4 # Index 5 # Total: 4 # ------------------------------------------------------------------------------------------------- # Problem 4 # Description: The numbers are almost sorted. # Compare the current array with the sorted array and print the minimum number of swaps required. # Note: Calculate this by printing: # Input Example: 2 4 7 7 9 3 # Output Example: 3
To embed this project on your website, copy the following code and paste it into your website's HTML: