Python is a popular programming language used to give instructions to computers. It helps people build websites, develop applications, automate tasks, create artificial intelligence systems, and analyse data.
Python is one of the best programming languages for beginners because its instructions are simple and easy to read.
Example: Imagine you own a supermarket in Ibadan. Every day, you record the amount of money you make from selling rice, beans, garri, and soft drinks. Instead of calculating everything manually, you can use Python to calculate your total sales and identify your best-selling products.
Python makes these calculations faster and easier.
Data analysis is the process of collecting, organising, cleaning, and studying information to discover useful facts and make better decisions.
Data can be numbers, names, dates, prices, examination scores, customer records, or sales information.
Example: Students' Examination Scores
Imagine a teacher records the examination scores of four students:
| Student | Score |
|---|---|
| Ada | 85 |
| Tunde | 70 |
| Musa | 90 |
| Grace | 65 |
By analysing these scores, we can discover:
Studying information to discover these facts is called data analysis.
Python is widely used in data analysis because it helps people work with information quickly and efficiently.
Here are five important reasons:
Python is used in many industries to understand information and solve real-world problems.
Nigerian Business Example:
A supermarket in Lagos records its daily sales. A data analyst can use Python to discover which products sell most during weekends and which products customers buy less often.
The supermarket can use this information to plan its stock, avoid running out of popular products, and reduce waste.
Before using Python, you need a programming environment where you can write and run instructions.
Some popular tools include:
Beginner's Tip: Google Colab is a good place to start because you can practise Python without installing it on your computer.
Let's write our first Python program.
Python uses a command called print() to display information on the screen.
Example 1:
print("Hello, Data Analyst!")
Output:
Hello, Data Analyst!
The print() command tells Python to display the message inside the brackets.
Example 2:
print("Welcome to Python for Data Analysis")
print("I am learning how to analyse data")
Output:
Welcome to Python for Data Analysis
I am learning how to analyse data
You can use the print() command to display names, numbers, messages, and calculation results.
Imagine a shop owner wants to calculate the total sales made in three days.
The sales records are:
Python can calculate the total automatically.
Python Code:
monday = 15000
tuesday = 20000
wednesday = 25000
total_sales = monday + tuesday + wednesday
print(total_sales)
Output:
60000
The shop made โฆ60,000 in total sales.
Notice that we used words such as monday, tuesday, and wednesday to store the sales figures. These are called variables.
A variable is a named storage location that holds information in a computer program.
In this module, you have learned that:
Now it is time to practise what you have learned.
A small shop sells the following products:
Your Task: Write a Python program that calculates the total amount made from selling these three products.
Hint: Create one variable for each product, add the three variables together, and use print() to display the total.
Python is a powerful tool that helps data analysts work with information. You do not need to be an expert programmer to get started. Learn the basics, practise regularly, and gradually build your data analysis skills.