Introduction to Python

0
372

Python is a high-level, interpreted programming language known for its simplicity and readability. It is widely used in web development, data science, artificial intelligence, automation, and more.

Why Learn Python?

  • Easy to Learn: Simple syntax similar to English.
  • Versatile: Used for web development, automation, AI, data science, etc.
  • Large Community: Many resources and support available.
  • Extensive Libraries: Offers libraries for various tasks like NumPy (scientific computing), Pandas (data analysis), TensorFlow (AI), Flask (web development), and more.

Basic Syntax

  1. Printing Output
    print("Hello, World!")
    
  2. Variables & Data Types
    name = "Alice"   # String
    age = 25         # Integer
    height = 5.6     # Float
    is_student = True # Boolean
    
  3. Data Structures
    my_list = [1, 2, 3, 4, 5]       # List
    my_tuple = (1, 2, 3, 4, 5)      # Tuple
    my_set = {1, 2, 3, 4, 5}        # Set
    my_dict = {"name": "Alice", "age": 25} # Dictionary
    
  4. Conditional Statements
    age = 18
    if age >= 18:
        print("You are an adult.")
    else:
        print("You are a minor.")
    
  5. Loops
    # For Loop
    for i in range(5):
        print(i)
    
    # While Loop
    count = 0
    while count < 5:
        print(count)
        count += 1
    
  6. Functions
    def greet(name):
        return f"Hello, {name}!"
    
    print(greet("Alice"))
    

Next Steps

  • Learn about Object-Oriented Programming (OOP) in Python.
  • Explore file handling, error handling, and database operations.
  • Work on projects like web scraping, data analysis, and machine learning.