1. Introduction to Python

What is Python?

Python is a high-level, interpreted, and general-purpose programming language created by Guido van Rossum and released in 1991.

Python is designed to be:

  • Easy to read
  • Simple to learn
  • Powerful for real-world applications

It is widely used in:

  • Web development
  • Data Science
  • Artificial Intelligence
  • Automation
  • Game development
  • Cybersecurity
  • Software development

Example of Python code:

print("Hello, World!")

Features of Python

1. Easy to Learn and Read

Python uses simple English-like syntax.

name = "Aditya"
print(name)

2. Interpreted Language

Python code runs line by line using an interpreter.

No compilation required before execution.


3. Platform Independent

Python works on:

  • Windows
  • Linux
  • macOS

Same code can run on different operating systems.


4. Open Source

Python is free to use and has a huge community.

Official website:
https://www.python.org


5. Object-Oriented

Python supports:

  • Classes
  • Objects
  • Inheritance
  • Polymorphism

6. Large Standard Library

Python provides built-in modules for:

  • File handling
  • Math
  • Web requests
  • Data processing
  • Database access

7. Supports Multiple Programming Styles

Python supports:

  • Procedural programming
  • Object-oriented programming
  • Functional programming

8. Huge Community Support

Millions of developers contribute tutorials, libraries, and solutions.


Installing Python

Step 1: Download Python

Visit:

https://www.python.org/downloads

Download the latest version.


Step 2: Install Python on Windows

During installation:

✅ Check:

Add Python to PATH

Then click:

Install Now

Step 3: Verify Installation

Open Command Prompt and type:

python --version

or

python3 --version

Example output:

Python 3.12.0

Python IDEs and Editors

What is an IDE?

IDE = Integrated Development Environment

It helps programmers write, run, and debug code.


1. IDLE

IDLE comes pre-installed with Python.

Features:

  • Simple interface
  • Good for beginners
  • Syntax highlighting

How to Open:

Search:

IDLE

in Windows Start Menu.


2. VS Code

Visual Studio Code is a popular lightweight editor.

Features:

  • Fast
  • Extensions support
  • Debugging tools
  • Git integration

Installation:

  1. Download VS Code
  2. Install Python extension

Website:
https://code.visualstudio.com


3. PyCharm

Professional Python IDE by JetBrains.

Features:

  • Smart code completion
  • Debugging
  • Project management
  • Django support

Versions:

  • Community Edition (Free)
  • Professional Edition (Paid)

Website:
https://www.jetbrains.com/pycharm/


4. Jupyter Notebook

Used mostly for:

  • Data Science
  • Machine Learning
  • Research

Features:

  • Run code cell by cell
  • Supports graphs and visualization
  • Interactive environment

Install using:

pip install notebook

Run using:

jupyter notebook

Running Python Programs

Method 1: Using Python Shell

Open terminal and type:

python

Then write:

print("Hello")

Method 2: Using Python File

Create a file:

hello.py

Add code:

print("Hello World")

Run:

python hello.py

Python Syntax Basics

Python syntax is simple and readable.


1. Print Statement

print("Welcome to Python")

2. Variables

name = "Aditya"
age = 25

3. Indentation

Python uses indentation instead of braces.

Correct:

if 5 > 2:
print("Five is greater")

Incorrect:

if 5 > 2:
print("Error")

4. Case Sensitive

name = "Aditya"
Name = "Kumar"

Both are different variables.


Comments and Documentation

What are Comments?

Comments are notes in code ignored by Python.

Used to explain code.


Single-Line Comment

# This is a comment
print("Hello")

Multi-Line Comment

"""
This is a
multi-line comment
"""

or

'''
Multi-line comment
'''

Documentation Strings (Docstrings)

Used to describe functions, classes, or modules.

Example:

def add(a, b):
"""
This function adds two numbers
"""
return a + b