You want to learn artificial intelligence, but you do not know where to start.
Should you learn Python first? Do you need strong mathematics? Can you build something useful as a beginner?
Start with small programs that solve everyday problems. Calculate a shop bill, check student marks, or record daily expenses. These examples help you understand the programming skills you will later use in AI.
Let us understand this step by step.
First, Understand the Connection Between Python and AI
Python is a programming language. We use it to give instructions to a computer.
For example, a shopkeeper wants to calculate the total price of three notebooks:
price = 150
quantity = 3
total = price * quantity
print(total)
The output is:
450
Here, we have given the computer an exact calculation.
Now imagine the shopkeeper wants to estimate how many notebooks customers will buy next week.
We could use previous sales records to train a machine learning model. The model looks for patterns in those records and uses them to make an estimate.
Machine learning is one part of AI. Python helps us prepare the data, train the model, and check its predictions.
Step 1: Learn Variables, Input, and Calculations
A variable stores a value, such as a name, price, or quantity.
Let us take a delivery example. A customer orders a meal, and we need to add the delivery charges.
meal_price = 800
delivery_charges = 150
total_bill = meal_price + delivery_charges
print("Total bill:", total_bill)
The output is:
Total bill: 950
Next, let the customer enter the meal price:
meal_price = float(input("Enter meal price: "))
delivery_charges = 150
total_bill = meal_price + delivery_charges
print("Total bill:", total_bill)
You have now learned how to receive information, store it, and perform a calculation.
Try it yourself. Make a program that calculates your monthly internet, electricity, and transport expenses.
Step 2: Learn Conditions
Conditions help a program choose what to do.
Suppose a shop offers free delivery on orders of Rs. 3,000 or more.
order_amount = 3500
if order_amount >= 3000:
print("Free delivery")
else:
print("Delivery charges: Rs. 150")
The program checks the amount and selects the correct message.
This is a rule that we wrote ourselves. It is ordinary programming.
Later, a machine learning model could learn from previous orders to estimate whether a customer is likely to order again. That requires examples and training.
Try it yourself. Create a program that checks whether a student has passed. Use 50 as the passing mark.
Step 3: Learn Lists and Loops
A list stores several values. A loop repeats an action.
Suppose a shopkeeper records sales for five days:
daily_sales = [2500, 3000, 1800, 4200, 3500]
total_sales = 0
for sale in daily_sales:
total_sales = total_sales + sale
print("Total sales:", total_sales)
Instead of adding each amount separately, the loop processes every value.
You will use the same idea when working with hundreds or thousands of records.
Try it yourself. Store seven days of expenses in a list. Calculate the total and the average daily expense.
Step 4: Learn Functions
A function stores instructions that you can reuse.
Suppose you regularly calculate discounted prices:
def calculate_final_price(price, discount_percent):
discount_amount = price * discount_percent / 100
final_price = price - discount_amount
return final_price
result = calculate_final_price(2000, 10)
print("Final price:", result)
The output is:
Final price: 1800.0
You can now use this function for different products.
In an AI project, functions can help you clean records, prepare inputs, and display predictions.
Before moving forward, also practise dictionaries, reading files, and handling errors such as someone entering text where a number is required.
Step 5: Learn How to Work With Data
Data means recorded information.
For a shop, it might include:
| Day | Customers | Sales in Rs. |
|---|---|---|
| Monday | 20 | 10,000 |
| Tuesday | 25 | 12,500 |
| Wednesday | 15 | 7,500 |
Before using this information, check it.
Is a sales amount missing? Has the same day been entered twice? Does one row contain text instead of a number?
These problems matter because a model learns from the data you provide.
Start with a small CSV file. A CSV file stores information in rows and columns and can also be opened in Excel.
Step 6: Learn the Main Data Libraries
A library is a collection of ready-made tools. You use these tools instead of writing everything yourself.
Learn these gradually:
| Library | What you use it for | Simple example |
|---|---|---|
| NumPy | Working with numerical arrays | Calculate with many measurements |
| Pandas | Reading and organising tables | Check a shop’s sales records |
| Matplotlib | Drawing charts | Show sales for each day |
| Scikit-learn | Training and evaluating machine learning models | Estimate a numerical value from past examples |
Start with Pandas and a small table. Read the file, display its rows, and calculate total sales. Then draw a chart.
With Scikit-learn, you can practise training models from examples and evaluating their predictions.
Step 7: Learn the Mathematics as You Need It
Begin with averages, percentages, graphs, and simple equations.
For example, if your shop sells 100, 120, and 140 notebooks over three weeks, the average is:
Average = (100 + 120 + 140) / 3
Average = 120
That average gives you a simple starting estimate. Later, you can check whether a machine learning model makes better estimates.
As you progress, learn probability, statistics, and linear algebra. You can begin Python practice while developing these skills.
Step 8: Build Your First Machine Learning Project
Try a used laptop price estimator.
Your records could contain:
| RAM in GB | SSD in GB | Age in years | Price in Rs. |
|---|---|---|---|
| 8 | 256 | 4 | 45,000 |
| 16 | 512 | 2 | 85,000 |
| 8 | 512 | 3 | 60,000 |
These are invented examples to explain the idea, not market prices.
The RAM, storage, and age are the inputs. The price is the value you want to predict.
Three rows are only enough to explain the structure. A useful estimator needs many more relevant records, including details such as processor, condition, and brand.
Your project should follow these steps:
- Collect and check the records.
- Keep some records aside for testing.
- Train the model on the remaining records.
- Predict prices for the test records.
- Compare the predictions with their actual prices.
Think of it like teaching a student. Practising questions helps them learn. New questions help you check their understanding.
Machine learning models should also be evaluated on examples they did not see during training.
A Simple Learning Schedule
Use this as a flexible plan:
| Stage | What to learn | What to build |
|---|---|---|
| Weeks 1–2 | Variables, input, conditions | Bill calculator |
| Weeks 3–4 | Lists, loops, functions | Expense tracker |
| Weeks 5–6 | Files, Pandas, data cleaning | Sales report |
| Weeks 7–8 | NumPy, charts, basic statistics | Sales analysis |
| Weeks 9–12 | Machine learning and evaluation | Laptop price estimator |
You may need more time, and that is fine. Move forward when you can explain and modify your own program.
Start With One Small Problem
Your first task is simple: write a program that records seven daily expenses and calculates the total.
Then improve it. Add categories, save the records in a file, and draw a chart.
Each improvement teaches you another part of the roadmap.
At Cody.pk, begin with Python fundamentals, practise with real examples, and build towards data analysis and AI one project at a time.
Give your first idea a try.
Start with variables, conditions, loops and functions in our Python course. Practise everyday examples, then build towards data analysis and AI.

