# Where to Find Beginner-Friendly Example Scripts in AI for Beginners: A Complete Guide

> Find beginner AI example scripts in the AI For Beginners repository. Explore the examples and lessons directory for runnable notebooks and hands-on AI learning.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: how-to-guide
- Published: 2026-08-22

---

**All beginner-friendly example scripts in the Microsoft AI for Beginners repository are located in the top-level `examples/` directory, with additional runnable notebooks available throughout the `lessons/` folder.**

The [microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners) repository provides a curated collection of self-contained Python scripts designed specifically for newcomers to artificial intelligence. These beginner-friendly example scripts demonstrate core AI concepts without requiring complex framework setup or deep theoretical background. Each file in the `examples/` directory can be executed directly with `python <script>.py` to see immediate results.

## Core Example Scripts in the examples/ Directory

The `examples/` folder contains three foundational scripts that progress from basic pattern recognition to neural networks and natural language processing.

### Linear Pattern Learning with 01-hello-ai-world.py

The [`01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/01-hello-ai-world.py) script demonstrates the simplest form of machine learning: learning the linear rule *y = 2x* using pure Python without external libraries.

```python
class SimpleAILearner:
    def __init__(self):
        self.weight = random.uniform(0, 5)      # initial guess

        self.learning_rate = 0.01

    def train(self, training_data, epochs=100):
        for epoch in range(epochs):
            for x, y_actual in training_data:
                y_pred = self.weight * x
                error = y_actual - y_pred
                self.weight += self.learning_rate * error * x

```

This implementation shows how a single **weight** parameter adjusts through iterative error correction, forming the conceptual foundation for more complex models.

### Building Neural Networks from Scratch in 02-simple-neural-network.py

The [`02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/02-simple-neural-network.py) file implements a single-layer perceptron complete with forward propagation, backpropagation, and decision boundary visualization.

```python
class SimpleNeuron:
    def __init__(self, num_inputs):
        self.weights = [random.uniform(-1, 1) for _ in range(num_inputs)]
        self.bias = random.uniform(-1, 1)

    def feedforward(self, inputs):
        total = sum(w * x for w, x in zip(self.weights, inputs)) + self.bias
        self.output = sigmoid(total)
        return self.output

```

As implemented in `microsoft/AI-For-Beginners`, this script reveals the internal mechanics of **activation functions** and **gradient descent** without abstraction layers.

### Text Sentiment Analysis Without External Libraries

The [`04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/04-text-sentiment.py) script provides a complete natural language processing example that learns word-level sentiment scores from labeled reviews and predicts sentiment for new sentences.

```python
class SimpleSentimentAnalyzer:
    def train(self, training_data):
        positive, negative = Counter(), Counter()
        for text, sentiment in training_data:
            words = self.preprocess_text(text)
            (positive if sentiment == 'positive' else negative).update(words)
        # Compute per-word sentiment scores

        for w in set(positive) | set(negative):
            self.word_scores[w] = (positive[w] - negative[w]) / (positive[w] + negative[w] + 1)

    def analyze(self, text):
        words = self.preprocess_text(text)
        avg_score = sum(self.word_scores.get(w, 0) for w in words) / max(len(words), 1)
        return ("positive" if avg_score > 0 else "negative", abs(avg_score) * 100, avg_score)

```

This file demonstrates **supervised learning** concepts using only Python's standard library, making it accessible before introducing TensorFlow or PyTorch.

## Advanced Examples in the lessons/ Directory

Beyond the introductory `examples/` folder, the repository includes topic-specific scripts within lesson directories that introduce popular frameworks.

### Computer Vision with PyTorch

Located at [`lessons/4-ComputerVision/07-ConvNets/pytorchcv.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/4-ComputerVision/07-ConvNets/pytorchcv.py), this script introduces convolutional neural networks using PyTorch. While more advanced than the base examples, it maintains beginner-friendly annotations and builds upon concepts introduced in the `examples/` directory.

### Natural Language Processing Embeddings

The [`lessons/5-NLP/14-Embeddings/torchnlp.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/5-NLP/14-Embeddings/torchnlp.py) file demonstrates how to work with word embeddings in PyTorch, bridging the gap between the simple sentiment analysis in [`04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/04-text-sentiment.py) and production-ready NLP pipelines.

## How to Run the Beginner-Friendly Scripts

Each script in the `examples/` directory is self-contained and requires only standard Python libraries.

1. Clone the repository:
   ```bash
   git clone https://github.com/microsoft/AI-For-Beginners.git
   cd AI-For-Beginners
   ```

2. Navigate to the examples directory:
   ```bash
   cd examples
   ```

3. Execute any script directly:
   ```bash
   python 01-hello-ai-world.py
   python 02-simple-neural-network.py
   python 04-text-sentiment.py
   ```

The scripts use `random` and `math` modules from Python's standard library, ensuring they run without pip installing dependencies.

## Summary

- **Location**: All beginner-friendly example scripts reside in the `examples/` directory at the repository root.
- **Key Files**: [`01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/01-hello-ai-world.py), [`02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/02-simple-neural-network.py), and [`04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/04-text-sentiment.py) provide progressive learning from linear regression to neural networks to NLP.
- **Self-Contained**: Each script runs with `python <filename>.py` and requires no external machine learning libraries.
- **Extended Learning**: The `lessons/` directory contains framework-specific examples like [`pytorchcv.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/pytorchcv.py) and [`torchnlp.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/torchnlp.py) for advancing beyond fundamentals.
- **Educational Structure**: Code demonstrates internal algorithms (backpropagation, gradient descent) explicitly rather than hiding them behind library calls.

## Frequently Asked Questions

### Where exactly are the beginner-friendly example scripts located in the AI for Beginners repository?

The beginner-friendly example scripts are located in the top-level `examples/` directory of the microsoft/AI-For-Beginners repository. This folder contains self-contained Python files that demonstrate core AI concepts without external dependencies, specifically [`01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/01-hello-ai-world.py), [`02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/02-simple-neural-network.py), and [`04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/04-text-sentiment.py).

### Do I need to install TensorFlow or PyTorch to run the example scripts?

No, the three main example scripts in the `examples/` directory require only Python's standard library. The [`01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/01-hello-ai-world.py), [`02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/02-simple-neural-network.py), and [`04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/04-text-sentiment.py) files use built-in modules like `random` and `collections` to implement algorithms from scratch. Framework-specific examples exist in the `lessons/` directory but are separate from the core beginner scripts.

### What is the difference between the examples/ directory and the lessons/ directory?

The `examples/` directory contains standalone Python scripts focused on fundamental algorithms implemented from scratch, while the `lessons/` directory contains Jupyter notebooks and framework-specific code (such as [`pytorchcv.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/pytorchcv.py) and [`torchnlp.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/torchnlp.py)) that accompany the curriculum and demonstrate production-ready implementations using TensorFlow and PyTorch.

### Can I modify and experiment with the code in these beginner-friendly scripts?

Yes, according to the repository's structure, these scripts are designed for experimentation. The classes such as `SimpleAILearner`, `SimpleNeuron`, and `SimpleSentimentAnalyzer` are implemented with clear variable names and adjustable parameters like `learning_rate` and `epochs`, making it straightforward to modify values and observe how changes affect the AI's learning behavior.