Q. Write a program to sort a dictionary's keys using bubble sort ...

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?