
Concept explainers
### Task 11 (8 points)
Write a Python program that takes a String as an input and
counts the frequency of each character using a dictionary. For solving
this problem, you may use each character as a key and its frequency as
values. \[You are not allowed to use the count() function\]
**Hint:**
1. You can create a new dictionary to store the frequencies.
2. Ignore case for simplicity (i.e. consider P and p to be the same).
3. keys need to be lower case
4. Do not count space. Remove space before counting.
===================================================================
**Sample Input:**
"Python
**Sample Output:**
{'p': 2, 'y': 1, 't': 1, 'h': 1, 'o': 2, 'n': 3, 'r': 2, 'g': 2, 'a': 1,
'm': 2, 'i': 2, 's': 1, 'f': 1, 'u': 1}
===========================
here is my code but I don't know what is wrong
def task11(in_str):
# YOUR CODE HERE
test_str = in_str.lower()
dict_out = {}
for i in test_str:
if i in dict_out:
dict_out[i] += 1
else:
dict_out[i] = 1
return dict_out
![In [61]: #todo
def task11(in_str):
# YOUR CODE HERE
test_strin_str.lower()
dict_out = {}
for i in test_str:
if i in dict_out:
dict_out[i]+= 1
else:
dict_out[i] = 1
return dict_out
In [60]: ning is fun") == {'p': 2, 'y': 1, 't': 1, 'h': 1, 'o': 2, 'n': 3, 'r': 2, 'g': 2, 'a': 1, 'm': 2, 'i': 2, 's': 1, 'f': 1, 'u': 1}
◄
AssertionError
Input In [60], in <cell line: 1>()
----> 1 assert task11("Python programming
'm': 2, 'i': 2, 's': 1, 'f': 1, 'u': 1}
AssertionError:
In [62]: task11("Python programming is fun")
Out [62]: {'p': 2,
'y': 1,
't': 1,
'h': 1.
'o': 2,
'n': 3,
': 3,
'r': 2,
'g': 2,
'a': 1.
'm': 2,
'i': 2.
's': 1,
'f': 1,
'u': 1}
Traceback (most recent call last)
is fun") == {'p': 2, 'y': 1, 't': 1, 'h': 1, 'o': 2, 'n': 3, 'r': 2, 'g': 2, 'a': 1,](https://content.bartleby.com/qna-images/question/a1d592a5-ec96-4b1d-bddf-23e27014debe/39b8a671-a12b-4575-abad-e361a6906493/5oj0nsq_thumbnail.png)

Step by stepSolved in 4 steps with 2 images

- Python 3 NO IMPORT PICKLE Please check the picture and add one more function(def) and fix the error in the code. Write a program that keeps names and email addresses in a dictionary as key-value pairs. You Must create and use at least 5 meaningful functions. A function to display a menu A function to look up a person’s email address A function to add a new name and email address A function to change an email address A function to delete a name and email address. This is the Required Output example: Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address…arrow_forward1.0) head Function Define and implement this function in data_utils.py. Purpose: Produce a new column-based (e.g. dict[str, list[str]1) table with only the first N (a parameter) rows of data for each column. Why: Visualizing a table with hundreds, thousands, or millions of rows in it is overwhelming. You frequently want to just see the first few rows of a table to get a sense you are on the correct path. Function name: head Parameters: 1. dict[str, list[str]]-a column-based table of data that will not be mutated 2. int - The number of "rows" to include in the resulting list • Return type: dict[str, list[str]] Implementation strategy: 1. Establish an empty dictionary that will serve as the returned dictionary this function is building up. 2. Loop through each of the columns in the first row of the table given as a parameter. 1. Inside of the loop, establish an empty list to store each of the first N values in the column. 2. Loop through the first N items of the table's column, 1.…arrow_forwardC++arrow_forward
- Q5/ write a program to compute the value of R from X,Y and Z values which are X=[0,1,2......9], Y= [2,4,6,.,20], and Z=(1,3,5,...,19]. Print the values of X,Y,Z, and R as adjacent columns. R = √A²+B²+C² X √x² + y² +2² A = . B=√36X* +9Y²+252² T C = √9+sin³Y+Z MATLABarrow_forwardneed help with python.arrow_forward# dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forward
- Data structure: Using Java,arrow_forwardDictionaries (100): Write a dictionary such that the following line of code holds or justify why this dictionary is not possible. In other words, what is dct? >>> dct['octopus'][(3,1,4)][True] ['Fish', 'Ocean'] (Check by plugging into python tutor)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





