PyVerse.io Step-by-Step Beginner Guide
Lesson: Setting Up Python and Jupyter Notebook
1) Welcome to PyVerse
- You’re about to set up your own coding lab! In this lesson, you’ll install Python and Jupyter Notebook so you can write, run, and save your programs in a friendly, click-and-run environment.
- No complicated math. No confusing jargon. Just clear steps and a few fun examples.
2) What You’ll Learn
- What Python and Jupyter Notebook are
- How to install Python (two easy options)
- How to open Jupyter Notebook and create your first notebook
- How to run your first pieces of code
3) What You Need
- A computer (Windows or macOS; Chromebook users see “Option C: Online”)
- An internet connection
- About 20–30 minutes
4) What Are Python and Jupyter Notebook?
- Python: A programming language that’s great for beginners and powerful for real-world projects.
- Jupyter Notebook: A tool that lets you write Python code in small sections (called “cells”), run them one by one, and see results right under the code. You can also add notes and titles.
5) Choose One Setup Path
Option A (Beginner-Friendly): Install Anaconda
- Best if you want an all-in-one install that includes Python, Jupyter Notebook, and popular data tools (like pandas and matplotlib).
- Steps:
- Go to anaconda.com/download.
- Download “Anaconda Distribution” for your operating system (Windows or macOS, 64-bit).
- Open the installer and follow the prompts.
- Windows: It’s okay to leave default options. If you see “Add Anaconda to my PATH,” you can leave it unchecked (Anaconda Navigator will handle things).
- Open “Anaconda Navigator” (from Start Menu on Windows or Applications on macOS).
- In Navigator, click “Launch” under “Jupyter Notebook.”
Option B (Lightweight): Install Python + Jupyter using pip
- Best if you want a smaller install or already have Python.
- Steps (Windows):
- Go to python.org/downloads and download the latest version for Windows.
- Run the installer. Important: Check “Add python.exe to PATH,” then click Install.
- Open Command Prompt (search “cmd”).
- Type:
- python --version (or py --version) to check Python
- pip --version to check pip
- Install Jupyter and common tools by typing:
- python -m pip install notebook matplotlib pandas
- Start Jupyter:
- jupyter notebook
- Steps (macOS):
- Go to python.org/downloads and download the macOS installer.
- Install Python.
- Open Terminal (Applications > Utilities > Terminal).
- Type:
- python3 --version to check Python
- pip3 --version to check pip
- Install Jupyter and common tools:
- python3 -m pip install notebook matplotlib pandas
- Start Jupyter:
- jupyter notebook
- If that doesn’t work, try: python3 -m notebook
Option C (No Install): Use Jupyter in the Browser
- Great for Chromebooks or school computers.
- Choices:
- Google Colab: Go to colab.research.google.com, click “New Notebook.” (Requires a Google account.)
- Try Jupyter (in browser): Go to jupyter.org/try-jupyter and choose “Notebook” or “JupyterLite.”
6) Open Your First Notebook
- If you launched from Anaconda Navigator: A browser window opens showing the Jupyter home page (your files).
- If you launched from the command line: It opens your default browser to the Jupyter home page.
- Create a new notebook:
- Click “New” (top-right).
- Choose “Python 3.”
- Rename it by clicking on “Untitled” at the top and typing something like “My_First_Notebook.”
7) Quick Tour of the Notebook
- Cell: A box where you write code or notes.
- Run a cell: Click inside it and press Shift+Enter (or use the “Run” button).
- Add a new cell: Click the + button in the toolbar.
- Save: Click the save icon (floppy disk) or press Ctrl/Cmd+S.
- Cell types:
- Code: Runs Python.
- Markdown: For titles and notes (useful for explaining your work).
8) Your First Small Steps in Python (Code Examples)
Example 1: Say hello and do simple math
- What this shows: print text, store values in variables, do basic addition.
# Example 1: Hello and simple math
name = "Sky" # Store a name
age = 14 # Store a number
print("Hello,", name) # Print a message
print("Next year you will be", age + 1)
Example 2: Work with a list and find an average
- What this shows: lists, sum, len, and printing results.
# Example 2: Lists and an average
daily_steps = [3000, 4500, 5000, 7000, 6500, 8000, 9000] # Steps for a week
total = sum(daily_steps) # Add them up
average = total / len(daily_steps) # Get the average
print("Total steps this week:", total)
print("Average steps per day:", average)
Example 3: Make a simple line chart (matplotlib)
- What this shows: importing a library and plotting data.
- If you used Anaconda, matplotlib is already installed.
- If you used Option B and get an error, install with: python -m pip install matplotlib (or python3 -m pip install matplotlib)
# Example 3: Plot steps by day
import matplotlib.pyplot as plt
days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
steps = [3000, 4500, 5000, 7000, 6500, 8000, 9000]
plt.plot(days, steps, marker='o') # Line with dots
plt.title("My Steps This Week")
plt.xlabel("Day")
plt.ylabel("Steps")
plt.grid(True) # Add grid lines
plt.show() # Display the chart
9) Practical Exercise (Your Turn!)
Goal: Create a notebook that greets the user and shows a tiny data chart.
- Steps:
- Create a new notebook named “Hello_Notebook.”
- In the first cell, write code that:
- Asks for the user’s name using input()
- Prints a friendly greeting using their name
- In a new cell, create a list of minutes you studied this week (7 numbers).
- Print the average study time.
- In another new cell, make a line chart of your study minutes by day (Mon–Sun).
- Hints:
- Use input("What is your name? ")
- Use sum(your_list) / len(your_list) for the average
- Use matplotlib like in Example 3
Bonus:
- Add a Markdown cell at the top with a title: “My Study Tracker”
- Change the line color in the plot: plt.plot(days, minutes, color="green", marker="o")
10) Common Troubleshooting (Quick Fixes)
- “python not found” or “command not recognized”:
- Windows: Close and reopen Command Prompt. Try py --version or python --version.
- macOS: Use python3 instead of python.
- “pip not found”:
- Try python -m pip install package_name (or python3 -m pip install package_name).
- Jupyter didn’t open in the browser:
- Look in the terminal for a link that starts with http://localhost:8888 and click it.
- If it opens the wrong folder, close Jupyter, go to the folder you want in File Explorer/Finder, then start Jupyter again.
- Plot doesn’t show:
- Make sure you called plt.show() after your plotting code.
11) Good Habits From Day One
- Create a folder called “pyverse-projects” for your notebooks.
- Save often.
- Add Markdown cells to explain what your code does.
- Never paste code from the internet unless you understand it.
Recap
- You learned what Python and Jupyter Notebook are and how to set them up.
- You installed Python using Anaconda (easy) or Python + pip (lightweight), or used an online option.
- You opened Jupyter Notebook, created a notebook, ran cells, and wrote simple code.
- You made your first chart and practiced with a small exercise.
- You’re ready to keep building awesome projects in PyVerse!