Question: Write a python script which does the following: 1. Takes in a command argument the location of a YAML file 2. Reads the YAML file

Write a python script which does the following:

1. Takes in a command argument the location of a YAML file

2. Reads the YAML file which contains a fruits and vegetables and their respective counts

3. Print to the console:

a. Total number of fruits

b. Total number of vegetables

c. Which fruit has the median value

d. Which vegetable has the median value

To do this, I want you to create the following methods/functions:

1. Reads a YAML file and returns a dictionary of fruits and dictionary of vegetables

2. Counts the values in a dictionary

3. Finds the median within a dictionary

4. Prints the console output in a single line

In addition to this script, I want you to create unit test using pytest and/or unittest which tests:

1. The passed in file is a YAML file

2. The YAML file contains a dictionary of fruits and vegetables

3. Create test for each method above

a. Example: for counts the values in a dictionary, test that the dictionary has string keys and integer values. Also that it calculates the count properly

Please explain the code thouroughly and how you implemented it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!