Understanding Data & Statistics
What is data?
Data is a collection of raw facts – numbers, text, images, sounds – recorded about something. When data is organised and processed so that it becomes meaningful, it is called information. Schools, banks, hospitals and apps all take decisions based on data.
Structured vs unstructured
Structured data
- Organised in rows and columns
- Fixed format (tables, spreadsheets, databases)
- Easy to search and analyse
- Example: marks sheet, railway reservation
Unstructured data
- No fixed format
- Text, images, audio, video, posts
- Needs special tools to analyse
- Example: emails, photos, YouTube videos
Data life cycle
- 1Collection – gather data from forms, sensors, surveys, websites
- 2Storage – save it in files, databases or the cloud
- 3Processing – clean, sort, calculate, summarise
- 4Analysis & presentation – tables, charts, reports
- 5Decision – use the information
Collection & storage
Data can be collected manually (registers, survey forms) or automatically (barcode scanners, sensors, online forms). It is stored in files (text, CSV), spreadsheets, databases (MySQL) or cloud storage. Storage devices include HDD, SSD and pen drives.
Processing data
Raw data often has blanks, spelling errors or invalid entries. Cleaning removes or fixes them before calculation.
# Processing raw data: clean, then summarise
raw = ['45', ' 67', 'abs', '89 ', '', '72']
clean = []
for v in raw:
v = v.strip()
if v.isdigit():
clean.append(int(v))
print('Valid:', clean, '| ignored:', len(raw) - len(clean))
print('Average:', round(sum(clean) / len(clean), 2))Statistical techniques
Statistics in Python
marks = [56, 72, 91, 72, 64, 85, 72, 48, 90, 60]
n = len(marks)
mean = sum(marks) / n
s = sorted(marks)
if n % 2 == 0:
median = (s[n // 2 - 1] + s[n // 2]) / 2
else:
median = s[n // 2]
mode = max(set(marks), key=marks.count)
print('Sorted:', s)
print('Mean :', mean)
print('Median:', median)
print('Mode :', mode)
print('Range :', max(marks) - min(marks))import statistics as st
marks = [56, 72, 91, 72, 64, 85, 72, 48, 90, 60]
print('mean :', st.mean(marks))
print('median :', st.median(marks))
print('mode :', st.mode(marks))
print('pstdev :', round(st.pstdev(marks), 2)) # population SD
print('pvar :', round(st.pvariance(marks), 2))Standard deviation
SD = √( Σ(x − mean)² ÷ n ). Steps: find the mean, subtract it from each value, square, average the squares (variance), take the square root.
# Standard deviation by formula, step by step
data = [4, 8, 6, 2]
m = sum(data) / len(data)
sq = [(x - m) ** 2 for x in data]
var = sum(sq) / len(data)
print('mean =', m)
print('squared deviations =', sq)
print('variance =', var, '| SD =', round(var ** 0.5, 3))Summary
- Data → processing → information.
- Structured data fits tables; unstructured data does not.
- Mean, median, mode, range and SD summarise a data set; Python's
statisticsmodule computes them.
