AI Tools Tutorial menu

AI Coding Assistants

AI coding assistants help you write, explain and fix code, but you must still understand and test everything they give you.

Types of Coding Assistants

TypeWhat it doesExamples
Chat assistantsYou paste code or a question, it replies with an answerChatGPT, Gemini, Claude
Editor assistantsSuggest code as you type, answer questions inside your editorGitHub Copilot, Gemini Code Assist, Cursor
Coding agentsRead your whole project, edit several files and run commands, then show you the changesClaude Code, Codex, agent modes in Copilot and Cursor

Most of these have a free tier or a free plan for students, plus paid plans with higher limits. Features change often, so check each tool's current page.

Asking for Code

Be specific: the language, what the code should do, the input, the output, and any rules.

Example

text
Write a Python function called total_bill that takes a list of item
prices in rupees and a discount percent. Return the final total rounded
to 2 decimal places. If the discount is more than 50, raise a ValueError.
Add 2 example calls.

A typical answer looks like this:

Example

python
def total_bill(prices, discount_percent):
    if discount_percent > 50:
        raise ValueError("Discount cannot be more than 50%")
    total = sum(prices)
    final = total - total * discount_percent / 100
    return round(final, 2)

print(total_bill([250, 480, 120], 10))
print(total_bill([1500], 0))
Output
765.0
1500.0

Before you use it, read every line. Do you understand why round(final, 2) is there? What happens with an empty list? If you cannot explain the code, ask the assistant to explain it, line by line.

Explaining Errors

AI tools are very good at explaining error messages. Paste the full error and the code that caused it:

Example

text
I am learning Python. This code gives an error. Explain the cause
simply and show the fix.

age = input("Enter your age: ")
print(age + 5)

TypeError: can only concatenate str (not "int") to str
Output
input() always returns text (a string), even if the user types a number.
Python cannot add the text "20" and the number 5.

Fix: convert the input to a number first.

age = int(input("Enter your age: "))
print(age + 5)

When learning, ask "explain why" instead of only "fix it". You will remember the reason and make the mistake less often.

Always Review and Test

AI-written code can look correct and still be wrong. It may:

  • Miss edge cases (empty lists, zero, negative numbers)
  • Use a library function that does not exist or has changed
  • Contain security problems, such as building SQL queries from user input
  • Solve a slightly different problem from the one you asked

A simple habit is to write small tests. Add these lines below the function:

Example

python
assert total_bill([100, 100], 10) == 180
assert total_bill([], 20) == 0
print("All tests passed")
Output
All tests passed

If a test fails, you have found a bug before your users did.

Working with Coding Agents

Coding agents can do larger jobs, like "add a contact form to this website" or "fix the failing tests". They work best when you:

  1. Describe the goal and the rules clearly (for example, "do not change the database")
  2. Use version control (Git), so you can see and undo every change
  3. Read the changes (the "diff") before accepting them
  4. Run the app and the tests yourself

Never let an agent run commands or push code you have not reviewed on an important project.

Will AI Replace Learning to Code?

No. Assistants make good programmers faster, but they cannot tell if the result is right for your client or your project. Employers still test whether you understand code. Use AI as a tutor and helper, not as a replacement for practice.

Good useRisky use
"Explain this error"Copying code you do not understand
"Suggest tests for this function"Submitting AI code as your own in an exam
"Review my code for bugs"Pasting company passwords or API keys into a chat

Exercise

Exercise

An AI assistant gives you a function that looks correct. What should you do before using it in your project?

Learn AI Tools with a teacher

Join the AI & Prompt Engineering course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp