Data Analysis With Python First Project Error HELP Error:TypeError: unsupported operand type(s) for -: 'dict' and 'dict'

I keep getting this error and don’t know whats wrong.

I used the same format for the output but still.

Project link: boilerplate-mean-variance-standard-deviation-calculator - Replit

To be exact this error means just that result returned by function is different than the expected one. Tests are using method, that can determine if two dictionaries are equal, but it is not able to determine how exactly they are differing.

I know but I don’t know how to solve it.

In the README.md file there’s expected result for one of the examples, compare it with what your function prints.

I did exactly that, even with the results from the tests, they’re exactly the same

There are some differences, take a closer look.

README.md file:

{
  'mean': [[3.0, 4.0, 5.0], [1.0, 4.0, 7.0], 4.0], 
  'variance': [[6.0, 6.0, 6.0], [0.6666666666666666, 0.6666666666666666, 0.6666666666666666], 6.666666666666667], 
  'standard deviation': [[2.449489742783178, 2.449489742783178, 2.449489742783178], [0.816496580927726, 0.816496580927726, 0.816496580927726], 2.581988897471611],
  'max': [[6, 7, 8], [2, 5, 8], 8],
  'min': [[0, 1, 2], [0, 3, 6], 0],
  'sum': [[9, 12, 15], [3, 12, 21], 36]
}

function output:

{
'mean': [[3.0, 4.0, 5.0], [1.0, 4.0, 7.0], 4.0], 
'variance': [[5.999999999999999, 5.999999999999999, 5.999999999999999], [0.6666666666666666, 0.6666666666666666, 0.6666666666666666], 6.666666666666666], 
'standard deviation': [[2.449489742783178, 2.449489742783178, 2.449489742783178], [0.816496580927726, 0.816496580927726, 0.816496580927726], 2.581988897471611], 
'max': [[6, 7, 8], [2, 5, 8], 8], 
'min': [[0, 1, 2], [0, 3, 6], 0], 
'sum': [[9, 12, 15], [3, 12, 21], 36]}

Yup now only one error left
but its the same “dict” one

result :{'mean': [[3.6666666666666665, 5.0, 3.0], [3.3333333333333335, 4.0, 4.333333333333333], 3.888888888888889], 'variance': [[9.555555555555557, 0.6666666666666666, 8.666666666666666], [3.555555555555556, 10.666666666666666, 6.222222222222221], 6.987654320987655], 'standard deviation': [[3.091206165165235, 0.816496580927726, 2.943920288775949], [1.8856180831641267, 3.265986323710904, 2.494438257849294], 2.6434171674156266], 'max': [[8, 6, 7], [6, 8, 7], 8], 'min': [[1, 4, 0], [2, 0, 1], 0], 'sum': [[11, 15, 9], [10, 12, 13], 35]}

expected : {'mean': [[3.6666666666666665, 5.0, 3.0], [3.3333333333333335, 4.0, 4.333333333333333], 3.888888888888889], 'variance': [[9.555555555555557, 0.6666666666666666, 8.666666666666666], [3.555555555555556, 10.666666666666666, 6.222222222222221], 6.987654320987654], 'standard deviation': [[3.091206165165235, 0.816496580927726, 2.943920288775949], [1.8856180831641267, 3.265986323710904, 2.494438257849294], 2.6434171674156266], 'max': [[8, 6, 7], [6, 8, 7], 8], 'min': [[1, 4, 0], [2, 0, 1], 0], 'sum': [[11, 15, 9], [10, 12, 13], 35]}

in the variance part , the last entry’s last digit differs and I don’t know why

Yup its fixed, thanks for the help!

Hi Waleedamiro, I’m having exactly the same error message. How did you solve it? Kindly help. Thanks

Br,
Oyebanji

When you got an issue, please open you own topic and ask for help, including a link to your project.

The error says you try to use “-” on two dicts. You solve this, but not trying to use “-” on two dicts.
For any further help, open a new topic.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.