Mean_var_std calculators

Tell us what’s happening:
The issue is I don"t know how else to write this code aside from I have written it

Your code so far

mport numpy as np

def calculate(list=range(10)):
calculations = {
“mean”: np.mean(list),
“variance”: np.var(list),
“standard_deviation”: np.std(list),
“minimum”: np.min(list),
“maximum”: np.max(list)

for values in calculations:


return calculate()


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55

Challenge: Mean-Variance-Standard Deviation Calculator

Link to the challenge:

Then you should take a Python course?
For a start, that code looks like you didn’t even read the instructions - as the key is supposed to be “min” not “minimum”.

Then you got a for-loop which does nothing because you didn’t include a print().

This is the second Python course, yet looking at your code, this hardly looks like you understand a lot of Python. Like, you “return calculate()” - what is that? Who does return that? Is that supposed to be WITHIN the calculate()-function? Then you just made a pointless infinite regression…

I’m sorry if this sounds mean, but you REALLY have to focus on your work.
We cannot help you if you didn’t even read the instruction properly and cannot say what you are struggling beyond “everything”. If you struggle with everything, you need to either redo the Python course OR look for another tutorial side that goes more step-by-step as I am aware the FCC course is only videos which is not so hands-on.

rather than slam yourself not me, why not just proffer a solution. you are acting like a demi god over a simple problem instead of proffering solution. goes to show a long way the kind of homo habilis you are.

Because the forum is meant to help people and sharing solutions is a violation of the rules.

On top of that, describing your problem and asking questions is an important part of the job of a developer. You didn’t ask a proper questions.

Finally, as I said, you code has several flaws which not only go against the task but are just plain pointless and even wrong code. What kind of help do you expect if you don’t even invest the work into your code to not create an obvious infinite regression within 15 lines?

import numpy as np

def calculate(list = ):
dic = {
“mean”: np.mean(list),
“variance”: np.var(list),
“standard_deviation”: np.std(list),
“max”: np.max(list),
“min”: np.min(list),
“sum”: np.sum(list)
if list == np.array([[“a”,“b”,“c”],[“d”,“e”,“f”],[“g”,“h”,“i”]]):
dic = list
return calculate(dic)

is this making sense?

You need 3 values for the mean - rows, columns and total. Please look at the documentation on how to get those.

I assume you want to do a pattern-match here. That’s not in the least the correct syntax and there is an easier way to check if a list contains 9 items.

I don’t know where you go the idea of returning the function… because that is a recursion.
You just need to return the dic.

Bonus: “list” is a Python keyword and should never be used as a variable name.

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