Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Introduction to Python

Lesson 16 of 37 in the free Data Science notes on Siksha Sarovar, written by Rohit Jangra.

Introduction to Python

What is Python?

Python is a high-level, interpreted, general-purpose programming language created by Guido van Rossum in 1991. It emphasizes code readability and simplicity, using significant indentation (whitespace) to define code blocks instead of curly braces or keywords.

Key Facts:

FeatureDetail
CreatorGuido van Rossum
Year1991
Latest VersionPython 3.x (Python 2 is deprecated since Jan 2020)
TypingDynamically Typed (no need to declare variable types)
ParadigmMulti-paradigm: Procedural, OOP, Functional
File Extension.py
InterpreterCPython (default), PyPy, Jython

---

Python vs Other Languages

FeaturePythonJavaC++JavaScript
SyntaxSimple, conciseVerboseComplexModerate
TypingDynamicStaticStaticDynamic
SpeedSlower (interpreted)Faster (compiled to bytecode)Fastest (compiled)Moderate
Use CaseData Science, AI, AutomationEnterprise, AndroidSystems, GamesWeb Development
Learning CurveEasyModerateSteepModerate
SemicolonsNoYesYesOptional

---

Installing Python

  1. Download from python.org.
  2. During installation, check "Add Python to PATH".
  3. Verify installation: Open terminal/command prompt and type python --version.

Popular IDEs and Editors:

  • Jupyter Notebook — Best for Data Science (interactive, cell-based).
  • VS Code — Lightweight, extensible editor with Python extension.
  • PyCharm — Full-featured IDE for professional Python development.
  • Google Colab — Free cloud-based Jupyter Notebook (no installation needed).

---

Your First Python Program

The classic "Hello, World!" program in Python is just one line:

print("Hello, World!")

Compare this to Java:

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Python's simplicity is immediately evident — one line vs. five.

---

Python's Indentation Rule

Python uses indentation (typically 4 spaces) to define code blocks, not curly braces {}. This enforces readable code by design.

Correct:

if True:
    print("Indented correctly")

Incorrect (will cause IndentationError):

if True:
print("No indentation")  # Error!

---

Comments in Python

TypeSyntaxExample
Single Line## This is a comment
Multi-LineTriple quotes """...""""""This is a multi-line comment"""

Python's Data Science Ecosystem

LibraryPurpose
NumPyNumerical computing, arrays
PandasData manipulation, DataFrames
MatplotlibData visualization (static plots)
SeabornStatistical visualization (beautiful plots)
Scikit-learnMachine Learning algorithms
TensorFlow / PyTorchDeep Learning frameworks
NLTK / spaCyNatural Language Processing
OpenCVComputer Vision

Summary

  • Python is a high-level, interpreted, dynamically-typed language created in 1991.
  • It is the most popular language for Data Science due to its simplicity and rich library ecosystem.
  • Python uses indentation for code blocks, making it inherently readable.
  • Jupyter Notebook and Google Colab are the preferred environments for data science work.