Question: This is using python 3.8, Please include docstring and keep the code clear and simple. This is for a 100 level CMPT class so in-depth

This is using python 3.8, Please include docstring and keep the code clear and simple. This is for a 100 level CMPT class so in-depth explanation would be helpful.

write the bodies of the functions. You will also find a test script named testing.py. It has a bunch of test cases pre-written for you. Read it carefully, Thank you!!!

This is using python 3.8, Please include docstring and keep the code

testing.py

clear and simple. This is for a 100 level CMPT class so

(b) (6 points) Implement the function count_in(). The interface for the function is: def count_in(node_chain, value): Purpose: Counts the number of times a value appears in a node chain Pre-conditions: :param node_chain: a node chain, possibly empty :param value: a data value Return: :return: The number times the value appears in the node chain A demonstration of the application of the function is as follows: empty-chain - None chain = N.node (1, N.node (2, N.node (1))) print('empty chain has', count_in(empty-chain, 1), 'occurrences of the valpe 1') print('chain has', count_in(chain, 1), 'occurrences of the value 1') The output from the demonstration is as follows: empty chain has O occurrences of the value 1 chain has 2 occurrences of the value 1 47 ###### 48 49 ################################################### #### UNIT TEST CASE: count in #### test_item = "count_in" 50 51 52 53 chain in = None value_in = None expected = 0 reason = 'Empty node chain' 54 55 56 result = a5q2.count_in(chain_in, value_in) if result != expected: print('Test failed: {}: got "{}" expected "{}" -- {}'.format(test_item, result, expected, reason)) 57 58 59 60 61 62 63 64 65 66 67 #### UNIT TEST CASE: count in #### chain_in = N.node(1) value_in = 0 expected = 0 reason = 'node chain with one node, value not present' 68 result = a5q2.count_in(chain_in, value_in) if result != expected: print('Test failed: {}: got "{}" expected "{}" -- {}'.format(test_item, result, expected, reason)) 69 70 71 72 73 74 75 76 77 78 79 #### UNIT TEST CASE: count in #### chain_in = N.node (7) value in = 7 expected = 1 reason = 'node chain with one node, value present' result = a5q2.count_in(chain_in, value_in) if result != expected: print('Test failed: {}: got "{}" expected "{}" -- {}'.format(test_item, result, expected, reason)) 80 81 82 83 84 #### UNIT TEST CASE: count in #### chain_in = N.node('one', N.node('two')) value_in = 7 expected = 0 reason = 'node chain with two nodes, value not present' 85 86

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!