Skip to content
OPQAI.
Sourced beginner / 🎓 Academic & Research Free tools

Learn Python Basics with AI Tutoring

Job to be done: Learn to code by writing programs with AI assistance

🇳🇬 Ways to use this in Nigeria

Ideas to get you started, adapt to your situation.

  • Student

    Learn Python basics by typing code with AI tutor to build a simple calculator for your project.

  • Entrepreneur

    Learn Python to automate simple tasks like data entry for your startup's operations.

  • 9-5 employee

    Learn Python to automate repetitive office tasks, like generating basic reports from data.

What you’ll get

You will learn to write and run basic Python code, such as printing text, asking for user input, and simple conditional logic. This approach uses AI as a tutor to guide you through writing code line by line, helping you understand what each part does.

Tools you need

  • Claude (freemium): An AI chatbot that can act as a tutor, explaining code and concepts.
  • ChatGPT (freemium): Another AI chatbot that can help with coding tasks and explanations.
  • Python interpreter (free): A program that runs your Python code. You can use online versions or install it on your computer.

Steps

  1. Start a new chat with your AI tutor: Open Claude or ChatGPT. You will ask it to help you learn Python by typing code yourself, with its guidance.

  2. Explain your goal: Tell the AI you want to learn basic Python and will type all the code yourself, with its help. For example:

    I want to learn Python. I will be typing out all the code myself, and I need you to act as a tutor. Please guide me step-by-step. Do not write the code for me, but explain what each line does and ask me questions about it.

    You should see the AI agree to help you learn in this way.

  3. Write your first Python command: The AI might suggest you start with printing text. Type the following line into your chat, then ask the AI to explain it:

    print("Hello, World!")

    The AI should explain that print() is a function that displays text on the screen, and the text inside the quotes is what will be shown.

  4. Ask for user input: Now, try asking the AI how to get input from the person using the program. It might suggest something like this. Type it out and then ask the AI to explain it:

    name = input("What is your name? ")
    print("Hello, " + name + "!")

    You should see the AI explain that input() gets text from the user, and the text inside the quotes is the question shown to the user. It will also explain how the name variable stores the answer, and how it’s used in the next print statement.

  5. Learn about conditional logic: Ask the AI how to make the program do different things based on a number. For example, ask it to explain this code:

    number = int(input("Enter a number: "))
    if number > 100:
        print("High")
    else:
        print("Low")

    You should see the AI explain that int() turns the user’s text input into a whole number, and the if/else statements check if the number is greater than 100 to decide whether to print “High” or “Low”.

  6. Practice with lists: Ask the AI how to create and print a list of items. Try this code:

    courtrooms = ["Courtroom 1", "Courtroom 2", "Courtroom 3"]
    for room in courtrooms:
        print(room)

    The AI should explain that courtrooms is a list, and the for loop goes through each item in the list and prints it on a new line.

  7. Combine inputs to get a sum: Finally, ask the AI how to take two numbers and add them. Type this code:

    num1 = int(input("Enter the first number: "))
    num2 = int(input("Enter the second number: "))
    total = num1 + num2
    print("The sum is: " + str(total))

    The AI should explain how it takes two inputs, converts them to numbers, adds them using the + operator, and then converts the total back to text using str() so it can be printed.

Original source

This workflow is inspired by a blog post by earlgreyhot1701d on DEV Community, where they explore learning to code by writing it themselves with AI assistance.

Notes & variations

  • Common mistake: Forgetting to convert input to a number using int() before doing math, or forgetting to convert a number back to text using str() before printing it with other text. Python will give an error if you try to add text and numbers directly.
  • Tip for better results: When the AI gives you code, try to explain it back to the AI in your own words. This helps solidify your understanding and shows the AI where you might be confused.
  • Alternative tools: You could also use Google Gemini (gemini.google.com) or other AI chatbots that allow you to type code and ask for explanations.

Keep going

More Academic & Research workflows