🔵 Data Science  ·  Lesson 42

Statistics for Data Science

What are Statistics Basics?

Statistics Basics means statistics helps summarize and understand data using mean, median, mode, range and standard deviation.

In real programs, this topic helps in summarising marks. Learn the idea first, then type the program yourself and compare the output.

💡 At a Glance
PointDetails
Course AreaData Science
Tools and concepts used to analyse, clean and present data.
Main Usesummarising marks
Example Filestatistics-basics.py
Practice FocusRun, change values, and explain the output line by line.

Why should you learn this?

  • It is useful for summarising marks.
  • It connects with understanding average and spread.
  • It improves your ability to read, write and debug Python programs.

Important Terms

These terms are used directly in this lesson. Understand them before memorising the code.

TermMeaning
meanAverage value.
medianMiddle value after sorting.
modeMost frequent value.
varianceSpread of data values.
standard deviationMeasure of spread around the mean.

Syntax / Basic Pattern

The simple pattern is: prepare data, apply the concept, then show the result.

Basic Pattern
import statistics as stats
marks = [80, 85, 85, 90, 100]
print("Mean:", stats.mean(marks))
print("Median:", stats.median(marks))
print("Mode:", stats.mode(marks))

Complete Example Program

Python – statistics-basics.py
import statistics as stats

marks = [80, 85, 85, 90, 100]
print("Mean:", stats.mean(marks))
print("Median:", stats.median(marks))
print("Mode:", stats.mode(marks))

Expected Output

Mean: 88 Median: 85 Mode: 85

Program Explanation

  • import statistics as stats imports ready-made features from a module/library.
  • marks = [80, 85, 85, 90, 100] stores a value in marks.
  • print("Mean:", stats.mean(marks)) displays information or calculated result on the screen.
  • print("Median:", stats.median(marks)) displays information or calculated result on the screen.
  • print("Mode:", stats.mode(marks)) displays information or calculated result on the screen.

Where will you use it?

  • Summarising marks.
  • Understanding average and spread.
  • Supporting ml decisions.

Common Mistakes

  • Analysing data before checking missing values, duplicates and data types.
  • Changing original data without keeping a clean copy.
  • Creating charts without title, labels or explanation.

Practice Tasks

  1. Type the program in statistics-basics.py and run it.
  2. Change input values or sample data and observe the new output.
  3. Create one example related to summarising marks.
  4. Write 5 lines explaining the logic in your own words.

Summary

Statistics Basics is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.

← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.