Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: USING PYTHON Ask the user how many numbers they want to input, then ask the user for that many numbers. Store those numbers in

Assignment: USING PYTHON

Ask the user how many numbers they want to input, then ask the user for that many numbers. Store those numbers in a list.

Write a function called bubble that takes 1 argument called L. This function will sort the list using a bubble sort.

And put these numbers into the site: 2,8,7,4,1,3,5,0,6 As the list is being sorted, print out the current state of the list the end of each pass Once done, print Done! and print the sorted list

Expected output format:

How many numbers do you want to sort? ...

Please input each number, one at a time, pressing enter between each: ... ...

You input the following numbers: 2,8,7,4,1,3,5,0,6

Pass 1: 2, 7, 4, 1, 3, 5, 0, 6, 8

Pass 2: 2, 4, 1, 3, 5, 0, 6, 7, 8

Pass 3: 2, 1, 3, 4, 0, 5, 6, 7, 8

Pass 4: 1, 2, 3, 0, 4, 5, 6, 7, 8

Pass 5: 1, 2, 0, 3, 4, 5, 6, 7, 8

Pass 6: 1, 0, 2, 3, 4, 5, 6, 7, 8

Pass 7: 0, 1, 2, 3, 4, 5, 6, 7, 8

The list is sorted! The sorted list is: 0, 1, 2, 3, 4, 5, 6, 7, 8

You can not use: sort function built into python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions