Lesson 1: Python Basics

What is Python?

Python is a high-level, interpreted programming language known for its simplicity and readability. It's widely used in AI because of its extensive libraries and frameworks.

Your First Python Program

Let's start with the classic "Hello, World!" program:

# This is a comment
print("Hello, World!")

Variables and Data Types

Python has several basic data types:

# Integer
age = 15

# Float
height = 5.9

# String
name = "Student"

# Boolean
is_student = True

# List
subjects = ["Math", "Science", "AI"]

Lesson 2: Control Structures

If-Else Statements

Conditional statements help your program make decisions:

score = 85

if score >= 90:
    print("Grade: A")
elif score >= 80:
    print("Grade: B")
else:
    print("Grade: C")

Loops

Loops help you repeat actions:

# For loop
for i in range(5):
    print(f"Number: {i}")

# While loop
count = 0
while count < 3:
    print(f"Count: {count}")
    count += 1

Lesson 3: Functions and Modules

Creating Functions

Functions help organize your code:

def calculate_area(length, width):
    """Calculate area of a rectangle"""
    area = length * width
    return area

# Using the function
result = calculate_area(5, 3)
print(f"Area: {result}")

Importing Modules

Python has many built-in modules:

import math

# Using math module
square_root = math.sqrt(16)
print(f"Square root of 16 is {square_root}")

Next Steps in AI

After mastering Python basics, you can explore:

  • NumPy for numerical computing
  • Pandas for data analysis
  • Matplotlib for data visualization
  • Scikit-learn for machine learning
  • TensorFlow or PyTorch for deep learning