Learn Python in Jupyter Notebook: 7 Steps for Beginners
ZMedia Purwodadi

Learn Python in Jupyter Notebook: 7 Steps for Beginners

Table of Contents

You installed Python, opened Jupyter Notebook, and then stared at an empty cell with no idea what to type. That is where most beginners in Nigeria get stuck. The tool is open, but the learning never starts. This guide fixes that. You will learn Python in Jupyter Notebook the practical way, by writing real code in the notebook itself, one small step at a time.

We will use one running example the whole way through, a week of POS sales for a small Lagos agent. Same data from the first cell to the last. By the end you will have written variables, a loop, a real dataset, a summary, and a chart, all inside Jupyter. No theory dumps. Just the exact steps you need to start.

If you have not set up the tool yet, read how to install Jupyter Notebook in Python first, then come back here.

Why learn Python in Jupyter Notebook first

Jupyter Notebook lets you run one small piece of code at a time and see the result straight away. That instant feedback is why it is the best place to learn Python using Jupyter Notebook as a complete beginner. You do not run a whole file and hope. You run one line, you see what happens, you fix it, you move on.

Each grey box in a notebook is called a cell. You type code in a cell, then press Shift and Enter together to run it. The output appears right below. Try this in your first cell.

# This is your first cell in Jupyter Notebook
# Type this, then press Shift and Enter to run it
print("Hello from Jupyter")

# Jupyter also shows the result of the last line on its own
2 + 2

You should see Hello from Jupyter and then the number 4. That is the whole loop of learning here. Write, run, read the output, repeat.

Store your first data in variables

A variable is just a name that holds a value. This is the foundation of everything you do when you learn Python in Jupyter Notebook. Let us start our running example. Chinedu runs a POS stand in Lagos and we want to track his sales in Naira.

# A variable holds one value
agent_name = "Chinedu"

# Sales in Naira from the POS machine
monday_sales = 45000
tuesday_sales = 38500

# You can do maths with variables
two_day_total = monday_sales + tuesday_sales

# Show the result
print(agent_name, "made", two_day_total, "Naira in two days")

Run that cell. The output reads Chinedu made 83500 Naira in two days. Notice you did not retype the numbers to add them. You used the variable names. Change monday_sales to a new figure, run again, and the total updates. That is the power of working in a notebook.

New to Python syntax itself? Our Python tutorial for beginners covers variables and data types in more depth.

Use a loop to total a full week

Two days is easy. What about seven? Typing every day by hand does not scale. A loop repeats an action for every item in a list, and this is where using Jupyter Notebook for Python starts to feel powerful.

# A list holds many values in order
# This is Chinedu's POS sales for the full week, in Naira
daily_sales = [45000, 38500, 52000, 41000, 60000, 72000, 33000]

# Start a running total at zero
total = 0

# The loop visits each amount one by one and adds it
for amount in daily_sales:
    total = total + amount

# Print the final total after the loop finishes
print("Total weekly sales:", total, "Naira")

The output is Total weekly sales: 341500 Naira. The loop did seven additions for you. If Chinedu adds a second machine next week, you just add the numbers to the list and run the cell again. Nothing else changes.

Quick pause. If following along and building real things is clicking for you, grab our free guide, 5 Real World Data Projects You Can Do With Python and SQL as a Beginner. It gives you full projects to practise on after this post.

Load real data with pandas in your notebook

A plain list works for one column of numbers. Real POS data has a date, an agent, and an amount. For that you need a table, and in Python the tool for tables is a library called pandas. A library is extra code someone already wrote that you can import and use. This step is the heart of learning Python with Jupyter Notebook for data work.

# Import the pandas library and give it the short name pd
import pandas as pd

# A dictionary maps each column name to its list of values
data = {
    "day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    "agent": ["Chinedu", "Amaka", "Bola", "Ngozi", "Emeka", "Chinedu", "Amaka"],
    "sales_naira": [45000, 38500, 52000, 41000, 60000, 72000, 33000]
}

# Turn that dictionary into a DataFrame, which is a table
df = pd.DataFrame(data)

# Show the table
df

Because this is the last line in the cell, Jupyter prints the table in a clean, readable grid. That is a real advantage of the notebook over a plain script. You see your data as an actual table, not a wall of text. Most beginners load their table from a file instead of typing it. When you are ready, see how to read a CSV file in Python.

Filter and summarise to find the answer

You have a table. Now ask it questions. Which days beat fifty thousand Naira? What is the average day? This is the reason people use Jupyter Notebook to learn Python for analysis. The answers come back instantly.

# Keep only the rows where sales were above 50000 Naira
big_days = df[df["sales_naira"] > 50000]
print(big_days)

# The average of the whole sales column
print("Average daily sales:", df["sales_naira"].mean())

# Group by agent and add up each person's total sales
print(df.groupby("agent")["sales_naira"].sum())

You learn three things at once. The strong days were Wednesday, Friday, and Saturday. The average day was about 48,785 Naira. And Chinedu, who worked two shifts, brought in 117,000 Naira, the most of any agent. That is a real business insight, pulled from a table in three short lines. To go deeper on this, read how to filter, group, and summarise data in Python with pandas.

Turn the numbers into a chart

Numbers are clearer as a picture. Jupyter shows charts right inside the notebook, directly under the code that made them. This is a moment where Jupyter Notebook for learning Python really pays off, because you see the plot appear the second you run the cell.

# Import the plotting library
import matplotlib.pyplot as plt

# Draw a bar chart of sales for each day
plt.bar(df["day"], df["sales_naira"])

# Always label a chart so it can be read on its own
plt.title("Daily POS Sales in Naira")
plt.xlabel("Day")
plt.ylabel("Sales (Naira)")

# Show the chart inside the notebook
plt.show()

A bar chart appears below the cell. The tall Saturday bar jumps out at once, which is the point. You built a full mini analysis, from raw numbers to a clear chart, without ever leaving Jupyter Notebook.

Save your work and keep the habit

Everything you did lives in one notebook file. Press Ctrl and S to save, or use File then Save. The file ends in .ipynb and it keeps both your code and its output, so you can reopen it tomorrow and continue exactly where you stopped.

The habit that makes people fluent is simple. Open a fresh notebook every few days and retype one of these steps from memory. Change the names to Amaka or Bola. Change the figures to transport fares or market prices. The more small notebooks you fill, the faster the syntax becomes second nature.

Summary of the 7 steps

StepWhat you learnedKey Python tool
1Run code one cell at a timeprint, Shift and Enter
2Store valuesVariables
3Repeat an action over a weekfor loop, list
4Hold data in a tablepandas DataFrame
5Filter and summarisemean, groupby
6Show a chartmatplotlib
7Save and repeat.ipynb file

What to do next

Do not close the notebook yet. Open a new cell and change the sales figures to your own numbers, then run every step again. Repetition inside the notebook is how the syntax sticks. Once you can rebuild these seven steps without looking, you are no longer a person who installed Jupyter. You are a person who can use it.

When you are ready to go from these basics to job ready skills, with structured lessons, real datasets, and projects built for the Nigerian market, that is exactly what Python for Data Analysts is built to do. It picks up right where this post ends and takes you all the way to analysis you can put on a portfolio.

References

For deeper reference on the tools used here, see the official documentation:

Post a Comment