Statistics Module Python Tutorial | Python statistics package

The statistics module comes with an assortment of goodies: Mean, median, mode, standard deviation, and variance. These are all fairly straight forward to use, ...searchHome+=1SupporttheContentCommunityLoginSignupHome+=1SupporttheContentCommunityLoginSignupStatisticsModulePythonTutorialSincePythonissuchapopularprogramminglanguagefordataanalysis,itonlymakessensethatitcomeswithastatisticsmodule.Sadly,thisisnotavailableinPython2.7,butthat'sokaybecausewe'reinPython3!Thestatisticsmodulecomeswithanassortmentofgoodies:Mean,median,mode,standarddeviation,andvariance.Theseareallfairlystraightforwardtouse,hereandsomesimpleexamples: importstatisticsexample_list=[5,2,5,6,1,2,6,7,2,6,3,5,5]x=statistics.mean(example_list)print(x)y=statistics.median(example_list)print(y)z=statistics.mode(example_list)print(z)a=statistics.stdev(example_list)print(a)b=statistics.variance(example_list)print(b)We'venotgonemuchoverimportingthingsinPython,soI'vekeptthisbasic.Asyoucansee,youjustsimplypassalistthroughthemodule'sfunction,andyou'reoutputistheanswer.Here,we'resavingtheoutputtoavariable,andthenwe'rejustprintingoutthevariable.Innormalcircumstances,you'dprobablycontinuedoingthingswithit.Here,we'veseenhowsimpleimportingandusingmodulescanbe,buttherearealotofotheroptionswhenitcomestohowweimportthings.Thenexttutorial:ModuleimportSyntaxPythonTutorialPythonIntroductionGoPrintFunctionandStringsGoMathwithPythonGoVariablesPythonTutorialGoWhileLoopPythonTutorialGoForLoopPythonTutorialGoIfStatementPythonTutorialGoIfElsePythonTutorialGoIfElifElsePythonTutorialGoFunctionsPythonTutorialGoFunctionParametersPythonTutorialGoFunctionParameterDefaultsPythonTutorialGoGlobalandLocalVariablesPythonTutorialGoInstallingModulesPythonTutorialGoHowtodownloadandinstallPythonPackagesandModuleswithPipGoCommonErrorsPythonTutorialGoWritingtoaFilePythonTutorialGoAppendingFilesPythonTutorialGoReadingfromFilesPythonTutorialGoClassesPythonTutorialGoFrequentlyaskedQuestionsPythonTutorialGoGettingUserInputPythonTutorialGoStatisticsMo


常見投資理財問答


延伸文章資訊