Q. Write a program to sort a dictionary's keys using bubble sort ...
文章推薦指數: 80 %
Q. Write a program to sort a dictionary's keys using bubble sort and produce the sorted keys ... Enter a dictionary : {9:"Python",2:"C++",7:"Java",3:"CSS"} HomePythonrevisionTour-2 Writeaprogramtosortadictionary’skeysusingbubblesortandproducethesortedkeysasalist. 2 Comments Facebook Twitter Q.Writeaprogramtosorta dictionary’skeysusingbubblesortandproducethesortedkeysasalist. YoucanunderstandbyWatchingvideo:- Answer:- dic=eval(input("Enteradictionary:")) key=list(dic.keys()) forjinrange(len(key)): foriinrange(len(key)-1): ifkey[i]>key[i+1]: key[i],key[i+1]=key[i+1],key[i] print(key) Output:-Enteradictionary:{9:"Python",2:"C++",7:"Java",3:"CSS"}[2,3,7,9]>>> Enteradictionary:{5:"Path",3:"Walla",4:"Portal",7:"Express"}[3,4,5,7]>>> «PreviousQuestion10 Next»Question12 2 Comments YoucanhelpusbyClickingonads.^_^Pleasedonotsendspamcomment:) Rjjai26April2022at23:20FirstoutpitiswrongReplyDeleteRepliesPathWalla29April2022at18:40Ok,Ihavecorrectedit.DeleteRepliesReplyReplyAddcommentLoadmore... PostaComment YoucanhelpusbyClickingonads.^_^Pleasedonotsendspamcomment:) PreviousPost NextPost SearchAnything:- Youcanhelpusbydonatingsmallamount Donate Weprovide- NCERTClass11CSSolution NCERTClass11IPSolution NCERTClass12CSSolution NCERTClass12IPSolution SumitaAroraClass12CSSolution SumitaAroraClass11CSSolution SumitaAroraClass12IPSolution SumitaAroraClass11IPSolution PreetiAroraClass12CSSolution PreetiAroraClass11IPSolution PreetiAroraClass12IPSolution PreetiAroraClass12CSSolution NotesClass12CS PreviousYearQuestionPaperClass12 PreviousYearQuestionPaperClass11 Contactform
延伸文章資訊
- 1Bubble sort python - Linux Hint
Bubble sort. This is the arranging of elements of an array that deals with using the simplest sor...
- 2Can you bubble sort a dictionary? - Quick-Advisors.com
How does a bubble sort work in Python?
- 3Python Program for Bubble Sort - GeeksforGeeks
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elem...
- 4python bubble sort Code Example
def bubbleSort(lis): length = len(lis) for i in range(length): for j in range(length - i): a = li...
- 512. Write a program to sort a dictionary's values using Bubble ...
Write a program to sort a dictionary's values using Bubble sort and produce the sorted values as ...