Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab02 - Exercise - Count (1 point) Open count.py and read the documentation for stub function count_char(). To better understand what the function needs to

image text in transcribed
image text in transcribed
image text in transcribed
Lab02 - Exercise - Count (1 point) Open count.py and read the documentation for stub function count_char(). To better understand what the function needs to do, write further tests in test_count.py. Each test should be its own function. Once you're satisfied you have a good set of tests, implement the count_char() function. Run your tests to ensure they pass. def count_char(input): Counts the number of occurrences of each character in a string. The result should be a dictionary where the key is the character and the dictionary is its count. For example, >>> count_char("Hello0o!") {'H': 1, 'e': 1, 'l': 2, 'o': 2, 'O': 1, '!': 1) from count import count_char def test_empty(): assert count_char("") def test_simple(): assert count_char("abc") == {"a": 1, "b": 1, "c": 1} def test_double(): assert count_char("aa") == {"a": 2}

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago