🔵 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
| Point | Details |
|---|---|
| Course Area | Data Science Tools and concepts used to analyse, clean and present data. |
| Main Use | summarising marks |
| Example File | statistics-basics.py |
| Practice Focus | Run, 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.
| Term | Meaning |
|---|---|
| mean | Average value. |
| median | Middle value after sorting. |
| mode | Most frequent value. |
| variance | Spread of data values. |
| standard deviation | Measure 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 statsimports 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
- Type the program in
statistics-basics.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to summarising marks.
- 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.
💻 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.