
In python:
Problem Statement:
The program takes a string and creates a dictionary with key as first character and value as the
count of letter in the string and also, sort the dictionary w.r.t the values of count in descending
order.
Pseudocode:
Start of build_dict function
An empty dictionary is declared
Start of for loop to traverse through the letters of the string
If letter is not present as a key in the dictionary
The letter is initialized as the key and assign 1 to it ( since initially the count would be 1)
Else
The value of the letter as key in the dictionary is increased by 1
End of build_dict function
Sort the dictionary and assign it back to the same dictionary variable
Start of print_dict function
Iterate over all the items of the dictionary
Print the key and value
End of print_dict function
Start of main function
User must enter a large string and store it in a variable
Call the build_dict function with string parameter and return the dictionary
Print dictionary using print_dict function
End of main function
Hint:- You can also use sorted function to sort the dictionary with respect to the values
associated with keys in descending order.
Sample input:-
enter word: ksbrfkdjsbkerf
Sample Output:[('k', 3), ('s', 2), ('b', 2), ('r', 2), ('f', 2), ('d', 1), ('j', 1), ('e', 1)]

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- run the program and please attach the screenshot of the outputarrow_forwardneed help with python...paste indented code here... QUESTION 6 Implement the following: a) Create a dictionary, grades, and initialize it with the following data:'Jimmy': 66 'Jerry': 80'Jacob': 71'James': 59'Jenny': 90 b) Use a loop to print all items of the dictionary grades as follows:name receives grade A (if the value is 90 or above).name receives grade B (if the value is 80 or above).name receives grade C (if the value is 70 or above).name receives grade D (if the value is 60 or above).name receives grade F (if the value is below 60). Example OutputJimmy receives grade D.Jerry receives grade B.Jacob receives grade C.James receives grade F.Jenny receives grade A.arrow_forwardcreate a function in python parameters: 1. dict[str, list[str]] 2. list[str] return type: dict[str, list[str]] must do like this: 1. establish an empty dictionary that will serve as the dictionary returned at the end 2. loop thorugh each of the columns in the second parameter of the function 2a. asssign to the column key of the result dictionary the list of values stored in the input dictionary at the same column 3. return the dictionary produced do not import other libraries such as pandas, .select, .head, .iloc or anything this function is being used to work in a dataframearrow_forward
- Pythonarrow_forwarduse python please function takes a dictionary as input and returns a string that contains the keys and values. the format of the string is 'key=value' with '&' separating each example: >>> function({'yes': 'correct', 'no': 'incorrect'}) output should be: 'yes=correct&no=incorrect' I am struggling to do this without an extra '&' at the endarrow_forwardPython code please help, indentation would be greatly appreciatedarrow_forward
- Overview This program will have you cut and past a dictionary called food_dict from the specifications, the programmatically go through the list to find people who have not yet listed their favorite foods. It will then ask for their foods, update the dictionary, and finally print it at the end. Note: I will change the dictionary during grading Expected Output Example 1 What is Janelle's favorite food? Steak What is Thomas's favorite food? What is Yolanda's favorite food? Soup Here are the favorite foods: Jim's favorite food is Tacos Bob's favorite food is Burgers Janelle's favorite food is Steak Lisa's favorite food is Pizza Thomas's favorite food is Pho Yolanda's favorite food is Soup Finn's favorite food is Bread Specifications • You should submit a single file called M4A5.py • It should follow the submission standards outlined here: Submission Standards • Your program must loop through the dictionary to find empty values. • You must copy this dictionary definition to the top of your…arrow_forwardPythonarrow_forwardI am trying to write a function using python that receives a list and builds a dictionary containing the position in the list where every item last appeared.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





