Python Full Notes

Python Full Notes

1. Introduction

Python is a high-level, interpreted programming language used for web development, data science, automation, and more.

2. Basic Syntax

    print("Hello, Python!")
    

3. Variables

    name = "Alice"
    age = 25
    

4. Data Types

    x = 10       # Integer
    y = 10.5     # Float
    z = "Hello"  # String
    

5. Conditional Statements

    if age >= 18:
        print("Adult")
    else:
        print("Minor")
    

6. Loops

    for i in range(5):
        print(i)
    

7. Functions

    def greet(name):
        return "Hello, " + name
    

8. Classes and Objects

    class Person:
        def __init__(self, name, age):
            self.name = name
            self.age = age

    p1 = Person("John", 30)
    print(p1.name)
    

9. Modules

    import math
    print(math.sqrt(25))
    

10. File Handling

    with open("file.txt", "r") as file:
        print(file.read())
    

11. Exception Handling

    try:
        x = 1 / 0
    except ZeroDivisionError:
        print("Cannot divide by zero!")
    

12. Popular Libraries

Some useful Python libraries:

  • NumPy – Numerical computations
  • Pandas – Data manipulation
  • Matplotlib – Data visualization
  • Requests – HTTP requests
  • Tkinter – GUI applications