Question

IN PYTHON Develop the program that will allow you to obtain an ordered list of whole...

IN PYTHON

Develop the program that will allow you to obtain an ordered list of whole numbers from least to greatest from two lists of whole numbers. The individual values ​​of the input lists are captured by the user one by one and then both lists will be joined and then sorted in ascending order (from lowest to highest value).
Your program should allow the capture of the entire values ​​of the lists without making use of messages (legends) to the user and will show the result in the form indicated below
To order:

You cannot use the sort or sorted function or any function already ordered. You will have to write it yourself. If you use any of these functions you will not have extra points.

I recommend you make a function called order (list) that receives a list and returns an ordered list.

The algorithm to sort would be more or less like this:
For each item in the list, one pass to the list will be made
On each pass, the element i will be checked with the i + 1 and if the element in i is larger than the element that is in i + 1, exchange them, continue checking until one before the end (so that in i + 1 you don't an index out of range comes out, in this way, the larger number will be 'pushed' to the end and it is not necessary to revise that element (your range may decrease each pass).
If there were no exchanges, it means that everything is already in order and it is not necessary to make more passes (you can use a Boolean variable to know if you made an exchange or not)

example:

3
1
4
5
*
2
9
6
1
3
*

OUTPUT

L1 = [3, 1, 4, 5]
L2 = [2, 9, 6, 1, 3]
LORDENADA = [1, 1, 2, 3, 3, 4, 5, 6, 9]

Example 2

*
*

output

L1 = []
L2 = []
LORDENADA = []
0 0
Add a comment Improve this question Transcribed image text
Answer #1

i def sortlist(a): # function to sort a list for i in range (len(a)): for j in range(len(a)-1): if a[j] > a[j+1]: alj), a[j+1

WOON * L1 = [3, 1, 4, 5] L2 = [2, 9, 6, 1, 3] LORDENADA = (1, 1, 2, 3, 3, 4, 5, 6, 9]

def sortList(a): # function to sort a list

for i in range(len(a)):

for j in range(len(a)-1):

if a[j] > a[j+1]:

a[j], a[j+1] = a[j+1], a[j]

return a

L1 = []

L2 = []

one = input() # user input of first list

while one != "*":

L1.append(int(one))

one = input()

one = input() # user input of second list

while one != "*":

L2.append(int(one))

one = input()

print("L1 =", L1) # printing two lists

print("L2 =", L2)

L1 = sortList(L1) # sorting two lists

L2 = sortList(L2)

LORDENADA = sortList(L1 + L2) # sorting merged list

print("LORDENADA =",LORDENADA) # printing output

# Please up vote. Happy Learning!

Add a comment
Know the answer?
Add Answer to:
IN PYTHON Develop the program that will allow you to obtain an ordered list of whole...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python program - Write a Python program, in a file called sortList.py, which, given a list...

    Python program - Write a Python program, in a file called sortList.py, which, given a list of names, sorts the names into alphabetical order. Use a one dimensional array to hold the list of names. To do the sorting use a simple sorting algorithm that repeatedly takes an element from the unsorted list and puts it in alphabetical order within the same list. Initially the entire list is unsorted. As each element is placed in alphabetical order, the elements in...

  • Python please For this program, we will be making lists for the local Zoo. You have...

    Python please For this program, we will be making lists for the local Zoo. You have been provided with 4 lists of data already created for you. Using this data, we update the data at this Zoo. YOU MUST USE LIST FUNCTIONS FOR REMOVING TO RECEIVE YOUR FULL POINTS! Input: A type of animal -- This information should be provided in response the question: "What animal are we removing?" A number corresponding to the selection of a menu number (see...

  • 8. Related to the merge sort is an efficient procedure called quick sort. Here we start...

    8. Related to the merge sort is an efficient procedure called quick sort. Here we start with a list L : a,a2,, an, and use a as a pivot to develop two sublists L and L2 as follows. For i > 1, if aa, place a at the end of the first list being developed (which is L1 at the end the process); otherwise, place a at the end of L2. After all a,, i >1, have been processed, place...

  • Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as...

    Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...

  • in C please 20. Change the bubble sort algorithm (Program 12-5) as follows: Use two directional...

    in C please 20. Change the bubble sort algorithm (Program 12-5) as follows: Use two directional bubbling in each pass. In the first bubbling, the smallest ele. ment is bubbled up; in the second bubbling, the largest element is bubbled I down. This sort is known as the shaker sort. 12-5 Bubble Sort (continued) // Statements // Each iteration is one sort pass for (int current = 0, sorted = 0; current <= last && !sorted; current++) for (int walker...

  • Write a web program to allow the user to sort a list of things. Use HTML...

    Write a web program to allow the user to sort a list of things. Use HTML and PHP. Your input (HTML) should include a text area the user can type in their list. The output (PHP) should be in the form of a table. Use the explode command to break the input up into an array. $list=explode(PHP_EOL, $stuff); Once you have the text into an array, use the sort function to sort it, and then loop through it and print...

  • Mergesort3: Your friend suggests the following variation of Mergesort: instead of splitting the list into two...

    Mergesort3: Your friend suggests the following variation of Mergesort: instead of splitting the list into two halves, we split it into three thirds. Then we recursively sort each third and merge them. Mergesort3 (A[1...n]):    If n <= 1, then return A[1..n]    Let k = n/3 and m = 2n/3    Mergesort3(A[1..k])    Mergesort3(A[k+1..m])    Mergesort3(A[m+1..n) Merge3(A[1..k], A[k+1,..m], A[m+1..n]) Return A[1..m]. Merge3(L0, L1, L2):    Return Merge(L0, Merge(L1,L2)). Assume that you have a function Merge that merges two sorted...

  • please help with python Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection...

    please help with python Write a well-documented, Python program, hmwk305.py that implements the Selection-Sort algorithm. Selection Sort segments the list into sorted and unsorted elements. The algorithm continues to remove the smallest element of the unsorted list and adds it to the sorted segment. Implement the algorithm that accepts an unsorted list and returns a sorted one - in ascending order. 5 3 8 4 6 Initial List Minimum Swaps Position: Sorted List Length 1 Minimum Swaps Position: Sorted List...

  • Use python to code! Q1 - You need to keep track of book titles. Write code...

    Use python to code! Q1 - You need to keep track of book titles. Write code using function(s) that will allow the user to do the following. 1. Add book titles to the list. 2. Delete book titles anywhere in the list by value. 3. Delete a book by position. Note: if you wish to display the booklist as a vertical number booklist , that is ok (that is also a hint) 4. Insert book titles anywhere in the list....

  • 2. Here is a sorting algorithm that I like to use. Given an unsorted list of...

    2. Here is a sorting algorithm that I like to use. Given an unsorted list of size n, let Xx represent the data in location k of the unsorted list. Compare xi to X2 and switch if necessary so that they are in sorted order, smallest first. Compare Xn-1 and Xn and switch if necessary so that they are in sorted order, smallest first. • Compare x3 with its left neighbors, switching if necessary so that the 3 first entries...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT