We use cookies to enhance your experience on the site
CodeWorlds

Welcome to Python Safari!

Welcome @name to Python Safari - the most exciting expedition in the world of programming! I'm Darwin, your guide on this fascinating journey through the Technology Jungle.

What Awaits You?

Before you lies an unexplored jungle full of mysteries, where Python is the language of nature, and AI creatures are wild, powerful beings waiting to be tamed. In this expedition:

  • 🐍 You'll learn the Python language from scratch
  • 🌴 You'll discover data structures like trails in the jungle
  • 🦁 You'll tame machine learning algorithms
  • 🦜 You'll create your own AI systems
  • 🌟 You'll build a project portfolio that will open doors to your career

What is Python?

Python is a programming language created in 1991 by Guido van Rossum. The name comes from... well, from a python! But not the snake - from the British comedy show "Monty Python's Flying Circus". How perfectly it fits our Safari!

Why is Python Popular?

Imagine you're going on an expedition. You can take:

  • Heavy equipment (C++, Java) - powerful, but requires a lot of effort
  • A light backpack (Python) - simple, elegant, sufficient for most tasks

Python is the explorer's universal tool:

1# Python is readable like natural language
2temperature = 30
3if temperature > 25:
4    print("It's hot in the jungle!")

Python in the Real World

1. Artificial Intelligence and Machine Learning

The greatest discoveries in AI:

  • ChatGPT, Claude, GPT-4 - built with Python
  • TensorFlow, PyTorch - AI frameworks created for Python
  • OpenAI, Google, Meta - use Python as their primary language

2. Data Science and Data Analysis

  • Netflix - movie recommendations (Python + ML)
  • Spotify - personalized playlists
  • NASA - data analysis from space missions

3. Web Development

  • Instagram - backend in Django (Python)
  • YouTube - large part of infrastructure in Python
  • Dropbox - desktop client in Python

4. Automation and Scripts

  • Task automation (web scraping, testing)
  • DevOps and infrastructure (Ansible, Terraform)
  • Scientific and research tools

First Steps - Installation

Before we head into the jungle, we need to prepare our equipment. Here's how to install Python:

Windows

  1. Go to python.org/downloads
  2. Download Python 3.12 or newer
  3. IMPORTANT: Check "Add Python to PATH"
  4. Click "Install Now"

macOS

1# Use Homebrew (if you don't have it, install from brew.sh)
2brew install python@3.12

Linux

1# Ubuntu/Debian
2sudo apt update
3sudo apt install python3.12
4
5# Fedora
6sudo dnf install python3.12

Verifying the Installation

Open a terminal/command prompt and type:

1python --version
2# or
3python3 --version

You should see: `Python 3.12.X` or a newer version.

Python Interactive Shell - Your First Tool

Python has a built-in interactive mode - like binoculars that let you quickly "see" the results of your code.

Type in the terminal:

1python
2# or
3python3

You'll see:

1Python 3.12.0 (main, Oct  2 2023, 12:00:00)
2[Clang 15.0.0 (clang-1500.0.40.1)] on darwin
3Type "help", "copyright", "credits" or "license" for more information.
4>>>

The `>>>` symbol is the prompt - Python is waiting for your commands!

Try it out:

1>>> print("Welcome to the Safari!")
2Welcome to the Safari!
3
4>>> 2 + 2
54
6
7>>> "Python" + " Safari"
8'Python Safari'
9
10>>> exit()  # Exit interactive mode

First Program - Hello Safari!

Let's create our first real program. Open a text editor (VS Code, PyCharm, Notepad++) and create a file called `hello_safari.py`:

1# My first Python Safari program!
2print("🌴 Welcome to the Python Jungle!")
3print("I'm ready for the expedition!")

Run it in the terminal:

1python hello_safari.py

Output:

1🌴 Welcome to the Python Jungle!
2I'm ready for the expedition!

Congratulations! You've just created your first Python program! 🎉

Comments - Explorer's Notes

On every expedition, a researcher takes notes. In Python, we use comments:

1# This is a comment - Python ignores it
2# It's used for explanations for humans, not for the computer
3
4print("This will execute")  # A comment can be at the end of a line
5
6"""
7This is a multi-line comment
8(docstring)
9Used for documentation
10"""

Basic Python Rules

1. Indentation is IMPORTANT

Python uses indentation to define code blocks (other languages use curly braces):

1# ✅ Correct
2if True:
3    print("This is indented")
4    print("This too")
5
6# ❌ Wrong - indentation error!
7if True:
8print("No indentation")

2. Case sensitivity - letter case matters

1name = "Python"
2Name = "Java"
3NAME = "C++"
4
5# These are THREE DIFFERENT variables!

3. Naming - conventions

1# Snake case for variables and functions (recommended in Python)
2my_variable = 10
3calculate_distance = lambda x: x * 2
4
5# CamelCase for classes
6class JungleAnimal:
7    pass

Print - Your Basic Communication Tool

The `print()` function displays information:

1# Simple display
2print("Text")
3print(123)
4print(3.14)
5
6# Multiple arguments
7print("Temperature:", 30, "degrees")
8
9# Separator
10print("A", "B", "C", sep="-")  # A-B-C
11
12# End character (default is newline)
13print("Line 1", end=" ")
14print("Line 2")  # Line 1 Line 2
15
16# F-strings (Python 3.6+) - the best way!
17name = "Darwin"
18temperature = 30
19print(f"Hello {name}, temperature: {temperature}°C")

Quiz - Check Your Knowledge

Before moving on, make sure you understand:

  1. What is Python?

    • A general-purpose programming language
    • Popular in AI, data science, web development
    • Simple and readable
  2. How do you run Python code?

    • Interactive mode: `python` in the terminal
    • File: `python filename.py`
  3. Does Python distinguish between uppercase and lowercase?

    • YES! `name` and `Name` are different variables
  4. What is indentation?

    • Spaces/tabs at the beginning of a line
    • They define code blocks
    • VERY IMPORTANT in Python!

Preparing for the Next Expedition

Before moving to the next lesson, make sure that:

  • [ ] You have Python installed (version 3.12+)
  • [ ] You can launch interactive mode
  • [ ] You've created and run your first program
  • [ ] You understand the importance of indentation
  • [ ] You know the basics of the `print()` function

What's Next?

In the next lesson we'll discover:

  • 🗺️ Variables - paths and signs in the jungle
  • 🔢 Data types - classifying discoveries
  • 🧮 Operators - the explorer's tools

Darwin is waiting for you at the next camp! Good luck, brave explorer! 🐍🌴

Go to CodeWorlds