Statistics and Python Programming Fundamentals
Understanding Quartiles, Deciles, and Percentiles
Quartiles divide ordered data into four equal parts. There are three quartiles: Q1, Q2, and Q3.
- Q1 (First Quartile): Tells about the point below which the first 25% of observations lie.
- Q2 (Second Quartile/Median): The middle value or median.
- Q3 (Third Quartile): Tells us about the point below which 75% of observations lie.
Deciles and Percentiles
Deciles divide an ordered dataset into 10 equal parts. They are represented by D1 through D9.
- D1: 10% position
- D5: 50% position
- D9: 90% position
Percentiles divide data into 100 equal parts, represented by P1 to P99.
Measures of Dispersion in Statistics
Dispersion refers to how much the data values are spread or scattered around a central value, such as the mean. The important measures are:
- Range
- Mean Deviation
- Variance
- Standard Deviation
- Coefficient of Variation
Range, Variance, and Standard Deviation
Range
Range in statistics is the difference between the highest value and the lowest value in a data set.
Formula: Range = Highest Value − Lowest Value
Example: 10, 15, 20, 25, 30
High = 30, Low = 10
Range = 30 − 10 = 20
Variance
Variance is the average of the squared differences between each data point and the mean. It shows how far data points are spread from the mean.
Formula: Variance = Σ(x − Mean)² / n
- x: Each value
- Mean: Average
- n: Total number of values
Standard Deviation
The square root of the variance. It is measured back to the original unit of the data, making it a widely used measure of dispersion. It tells us how much the data values are spread out from the mean.
Formula: Standard Deviation = √Variance
Coefficient of Variation (CV)
The Coefficient of Variation is a measure of relative variability or dispersion in a data set. It is used to compare the variability of two or more datasets.
Formula: CV = (Standard Deviation / Mean) × 100
Example: Mean = 50, Standard Deviation = 5
CV = (5 / 50) × 100 = 10%
Python Programming Fundamentals
Python is a high-level, interpreted language known for its simple and readable syntax. It was created by Guido van Rossum and is widely used in web development, data science, automation, AI, and more.
Key Features of Python
- Easy to Learn
- Free and Open Source
- Interpreted Language
- Large Library Support
- Dynamically Typed
- Platform Independent
- High Level
- Portable
Python Data Types
A data type is a classification that tells Python what kind of value a variable can store and what operations can be performed on it. Available data types include:
- Integer (int): Stores whole numbers without a decimal point.
- Float (float): Stores decimal numbers.
- Complex (complex): Stores complex numbers.
- String (str): Stores text and words.
- Boolean (bool): Stores True and False.
- List (list): Stores multiple changeable values.
- Tuple (tuple): Stores multiple fixed values.
- Set (set): Stores unique values.
- Dictionary (dict): Stores data in key-value pairs.
Python Operators
A Python operator is a symbol or keyword used to perform operations on values or variables. Types include:
- Arithmetic: Used for mathematical operations.
- Comparison: Used to compare two values.
- Logical: Used to combine conditions.
- Assignment: Used to assign a value to a variable.
- Bitwise: Used to perform bitwise operations.
- Membership: Used to check whether a value exists in a sequence.
- Identity: Used to check if two variables are the same object.
Variables and Input/Output in Python
A Variable is a name used to store data in a Python program during execution.
Rules for Naming Variables
- Must start with a letter or underscore (_).
- Cannot start with a number.
- Can contain letters, numbers, and underscores.
- Spaces are not allowed.
- Variable names are case-sensitive.
- Python keywords cannot be used as names.
Input and Output
Input means taking data from the user during program execution using the input() function. Python stores this value in a variable. Output means displaying information on the screen using the print() function.
Conditional Statements and Loops
Conditional Statements
These allow a program to make decisions based on whether a condition is true or false:
- if: Executes code only if the condition is true.
- if-else: Executes one block if true and another if false.
- if-elif-else: Checks multiple conditions and executes the first true one.
Loops in Python
- While Loop: Repeatedly executes code until its condition becomes false.
- For Loop: Repeats for a fixed number of times or over a sequence.
Data Structures: Lists, Tuples, and Arrays
Difference Between Lists and Tuples
- List: An ordered and changeable (mutable) collection. Elements can be added, removed, or modified. Uses square brackets
[ ]. It is generally faster than a tuple for certain operations and has many built-in methods. - Tuple: An ordered but immutable (unchangeable) collection. Elements cannot be modified after creation. Uses parentheses
( ). It is used for fixed data and has fewer built-in methods.
What is an Array?
An array is a collection of elements of the same type stored under one name, used to store multiple values in one variable.
Python Functions and Array Operations
Functions in Python
A function is a block of reusable code that performs a specific task, helping to organize code for better readability and reuse.
- Built-in Functions: Provided by Python (e.g.,
print(),len(),input()). - User-defined Functions: Created by the programmer using the
defkeyword.
Important Array Functions and Operations
- append(): Adds an element at the end of the array.
- insert(): Adds an element at a specific position.
- remove(): Removes a specified element.
- pop(): Removes an element, usually by its index.
- index(): Returns the position of an element.
- reverse(): Reverses the order of elements.
- count(): Counts occurrences of a particular element.
Quick Revision: append → add at end | insert → add at position | remove/pop → remove | index → find position.
English with a size of 8.01 KB