Welcome to Module Four!
In the previous module, you learned about databases and SQL. You discovered how organisations store information and how data analysts retrieve information from databases.
Now, let's explore another important part of data analysis: programming tools.
Imagine that a company has collected information about 100,000 customers. The company wants to calculate how much each customer spends, identify its most popular products, and discover buying patterns.
Doing all these calculations manually would take a very long time.
Programming tools allow data analysts to give computers instructions to perform these tasks automatically.
In this module, you will learn about Python, R, Jupyter Notebook, Pandas, and NumPy.
Programming means writing instructions that tell a computer what to do.
Think about giving someone directions to your school. You might say:
These instructions explain how to complete a task.
Programming works in a similar way. We write instructions using a programming language, and the computer follows those instructions.
Python is a popular programming language used for many activities, including data analysis, artificial intelligence, website development, and automation.
Python is popular because its instructions are relatively easy to read and understand.
Look at this simple instruction:
print("Hello, Data Analyst!")
This instruction tells the computer to display the words:
Hello, Data Analyst!
Another example:
print(10 + 20)
The computer will calculate the answer and display:
30
Imagine that a shop in Ibadan sells 15 bags of rice in the morning and 20 bags in the afternoon.
You can use Python to calculate the total number of bags sold.
morning_sales = 15
afternoon_sales = 20
total_sales = morning_sales + afternoon_sales
print(total_sales)
Result:
35
Python has calculated the total automatically!
A variable is a named place where a program stores information temporarily while it runs.
Think of a variable as a labelled container.
For example, imagine you have a box labelled Age. You put the number 13 inside it.
In Python, you can write:
age = 13
print(age)
The result will be:
13
You can also store names and other information.
student_name = "John"
score = 85
school = "CRMNuggets Academy"
print(student_name)
print(score)
print(school)
Variables make it easier to store and work with information.
A list allows you to store several items in one variable.
Imagine that you want to store the examination scores of five students.
Instead of creating five separate variables, you can use a list.
scores = [75, 80, 90, 65, 85]
print(scores)
Python will display:
[75, 80, 90, 65, 85]
You can also calculate the total and average of these scores.
scores = [75, 80, 90, 65, 85]
total = sum(scores)
average = sum(scores) / len(scores)
print("Total:", total)
print("Average:", average)
This is useful when working with examination results, sales records, and other datasets.
Jupyter Notebook is a tool that allows people to write and run programming code in separate sections called cells.
It is widely used by data analysts, researchers, teachers, and students.
Imagine that you want to calculate the average score of three students.
You can enter this code in a Jupyter Notebook cell:
scores = [70, 80, 90]
average = sum(scores) / len(scores)
print(average)
When you run the cell, Jupyter Notebook displays the answer.
Pandas is a Python library used for working with structured data.
A library is a collection of ready-made instructions that programmers can use instead of writing everything from the beginning.
Pandas is especially useful for working with information arranged in rows and columns.
First, we import the Pandas library.
import pandas as pd
Next, we create a small dataset.
data = {
"Name": ["John", "Mary", "David"],
"Score": [80, 90, 75]
}
students = pd.DataFrame(data)
print(students)
Expected result:
| Name | Score |
|---|---|
| John | 80 |
| Mary | 90 |
| David | 75 |
Pandas has organised the information into a table called a DataFrame.
A DataFrame is a table-like structure provided by Pandas.
It contains rows and columns, just like a spreadsheet.
For example, a school might have a DataFrame containing:
DataFrames make it easier to analyse information using Python.
import pandas as pd
data = {
"Student": ["John", "Mary", "David"],
"Score": [80, 90, 70]
}
students = pd.DataFrame(data)
average = students["Score"].mean()
print("Average Score:", average)
Result:
Average Score: 80.0
NumPy is another important Python library used for numerical calculations.
It helps programmers work with large collections of numbers efficiently.
First, import the NumPy library.
import numpy as np
Next, create an array of examination scores.
scores = np.array([70, 80, 90, 60, 100])
print(scores)
You can calculate the average:
average = np.mean(scores)
print(average)
Result:
80.0
NumPy makes numerical calculations easier when working with data.
R is a programming language designed mainly for statistical computing and data visualisation.
It is used by researchers, statisticians, scientists, and data analysts.
Imagine that you want to calculate the average examination score of five students.
scores <- c(70, 80, 90, 60, 100)
average <- mean(scores)
print(average)
Result:
[1] 80
R has calculated the average score automatically.
Python and R are both useful programming languages for data analysis.
| Feature | Python | R |
|---|---|---|
| Main Uses | Data analysis, automation, AI, and software development | Statistics, research, and data visualisation |
| Popular Libraries | Pandas and NumPy | dplyr and ggplot2 |
| Learning | Beginner-friendly syntax | Useful for statistical learning |
| Applications | Business, technology, science, and AI | Research, science, and statistics |
Both languages are valuable. You do not need to learn both immediately. Beginners can start with Python and explore R later.
Data analysts sometimes combine different programming tools to complete a project.
For example, imagine that a supermarket wants to understand its monthly sales.
Each tool performs a different task, but together they help solve the business problem.
You do not need an expensive computer to begin learning Python.
There are online tools that allow you to write and run Python code.
For beginners, Google Colab is a convenient starting point because you can practise Python in a web browser.
Imagine that you are a data analyst helping a teacher understand the examination performance of five students.
Use Python to complete the following tasks.
scores = [75, 80, 90, 65, 85]
print(scores)
total = sum(scores)
print("Total Score:", total)
average = sum(scores) / len(scores)
print("Average Score:", average)
highest = max(scores)
print("Highest Score:", highest)
lowest = min(scores)
print("Lowest Score:", lowest)
Your Challenge: Change the scores and run the program again. Observe how the answers change automatically.
Answer the following questions to test your understanding.
Congratulations! You have completed Module Four of Data Analysis Tools Overview.
In this module, you learned:
In the next module, you will discover how data analysts turn numbers into charts, graphs, and interactive dashboards. You will explore Microsoft Power BI, Tableau, and other tools used to present information in a simple and understandable way.
Keep practising your programming skills. You are building the foundation for a successful journey into data analysis!
CRMNuggets โ Learn. Practice. Get Certified.