Python Programming Language Tutorial
Master Python programming from basic syntax to advanced concepts including web development, data science, machine learning, automation, and more with practical examples.
Easy to Learn
Beginner friendly syntax
200+ Examples
Practical code samples
Data Science
AI/ML ready
Web Development
Django & Flask
Introduction to Python Programming
Python is a high-level, interpreted programming language known for its simplicity and readability. Created by Guido van Rossum and first released in 1991, Python has become one of the most popular programming languages worldwide, especially in data science, machine learning, web development, and automation.
History of Python
- Created by Guido van Rossum in 1991
- Inspired by ABC language
- Python 2.0 released in 2000
- Python 3.0 released in 2008
- Latest stable version: Python 3.12+
Why Learn Python?
- Simple and easy-to-learn syntax
- Extensive library support
- Versatile (Web, Data Science, AI, Automation)
- Large community and excellent documentation
- High demand in job market
First Python Program
Python programs are simple and readable. Here's the traditional "Hello, World!" program:
# Simple Hello World program in Python
print("Hello, World!")
# Python doesn't require semicolons
# Indentation is crucial in Python
Python Syntax Basics
Python syntax is clean and easy to understand. Unlike other languages, Python uses indentation (whitespace) to define code blocks.
# Variables don't need explicit declaration
message = "Hello, Python!"
# Conditional statement
if len(message) > 10:
print("Long message")
else:
print("Short message")
# For loop
for i in range(5):
print(f"Number: {i}")
# Function definition
def greet(name):
return f"Hello, {name}!"
print(greet("Developer"))
Variables and Data Types in Python
Python is dynamically typed - you don't need to declare variable types. Variables are created when you assign a value to them.
# Variable declaration and initialization
name = "John Doe" # String
age = 25 # Integer
salary = 45000.50 # Float
is_employed = True # Boolean
skills = ["Python", "Django", "Data Science"] # List
# Multiple assignment
x, y, z = 10, 20, 30
# Check variable type
print(type(name)) # <class 'str'>
print(type(age)) # <class 'int'>
print(type(is_employed)) # <class 'bool'>
Python Data Types Reference
| Data Type | Category | Description | Example |
|---|---|---|---|
| int | Numeric | Integer numbers (positive, negative, zero) | age = 25 |
| float | Numeric | Floating point numbers (decimal) | price = 19.99 |
| complex | Numeric | Complex numbers (real + imaginary) | z = 3 + 5j |
| str | Sequence | Text/string data (immutable) | name = "Python" |
| list | Sequence | Ordered, mutable collection | items = [1, 2, 3] |
| tuple | Sequence | Ordered, immutable collection | coords = (10, 20) |
| dict | Mapping | Key-value pairs (unordered) | person = {"name": "John", "age": 30} |
| set | Set | Unordered collection of unique items | unique = {1, 2, 3} |
| bool | Boolean | Logical values (True/False) | is_valid = True |
| NoneType | Special | Represents absence of value | result = None |
Python Applications
Data Science & Analytics
Python is the #1 language for data science with libraries like:
- NumPy: Numerical computing
- Pandas: Data manipulation
- Matplotlib/Seaborn: Data visualization
- Scikit-learn: Machine learning
Artificial Intelligence & ML
Leading AI/ML frameworks in Python:
- TensorFlow: Deep learning framework
- PyTorch: Research-focused ML
- Keras: High-level neural networks
- OpenCV: Computer vision
Web Development
Popular Python web frameworks:
- Django: Full-featured framework
- Flask: Microframework
- FastAPI: Modern API framework
- Pyramid: Flexible framework
Automation & Scripting
Python excels at automation tasks:
- File system operations
- Web scraping (BeautifulSoup, Scrapy)
- Task automation
- System administration
Python Key Advantages
- Easy to learn and read with clean syntax
- Dynamically typed - no need to declare variable types
- Extensive standard library and third-party packages
- Cross-platform compatibility (Windows, macOS, Linux)
- Excellent community support and documentation
- Versatile applications (Web, Data Science, AI, Automation)
- High demand in job market with competitive salaries