February 7, 2026

๐Ÿ AI Superheroes Workshop โ€“ Session 3: Coding Our Islamic Chatbot with Python

Time to become real coders! In this session, kids learn Python programming by bringing their Islamic chatbot designs to lifeโ€”one line of code at a time!

Ages 9โ€“14 90 minutes Beginner Python Islamic Values
๐Ÿ“‹ Session Overview

What We'll Learn Today

Welcome back, AI Superheroes! In Sessions 1 and 2, we learned what AI is and designed our Islamic chatbot "Noor." Today, we're going to learn how to actually build it using Pythonโ€”a friendly programming language that talks to computers!

๐ŸŽฏ Learning Goals

  • Understand Python โ€“ What it is and why it's perfect for chatbots
  • Learn basic coding โ€“ Variables, input/output, if/else, and lists
  • Build a real chatbot โ€“ Create a working Islamic chatbot in Python
  • Test and improve โ€“ Run our chatbot and add more features
  • Think like a coder โ€“ Break problems into small steps

๐Ÿ“– The Story of Python the Friendly Snake ๐Ÿ

Once upon a time, a man named Guido wanted to create a programming language that was easy to read and fun to useโ€”like having a friendly conversation with a computer!

He named it "Python" (after a funny TV show, not the snake!). Python became so loved that today, millions of people use it to build amazing things: chatbots, games, websites, and even AI!

Why do we love Python?

  • โœ… It's easy to read (almost like English!)
  • โœ… It's powerful (can build chatbots, games, AI)
  • โœ… It's friendly (great for beginners)
  • โœ… It's free (anyone can use it)
Session Timeline

90-Minute Adventure Plan

๐ŸŽฌ
0-10 min
Welcome & Story Time

Recap Sessions 1 & 2, introduce Python with the "Friendly Snake" story, show what we'll build today

๐Ÿ—๏ธ
10-25 min
Python Basics Part 1

Learn Variables & Print (storing information and showing messages)

๐ŸŽค
25-40 min
Python Basics Part 2

Learn Input & If/Else (asking questions and making decisions)

๐Ÿ“š
40-55 min
Python Basics Part 3

Learn Lists (storing many Q&A pairs like flashcards)

๐Ÿค–
55-75 min
Build Our Chatbot!

Put it all togetherโ€”code "Noor" the Islamic chatbot step by step

๐ŸŽ‰
75-85 min
Test & Celebrate

Run our chatbots, share with the group, celebrate being coders!

๐Ÿš€
85-90 min
What's Next?

How to extend the chatbot, practice at home, preview future sessions

๐Ÿ—๏ธ Part 1

Variables & Print: Storing & Showing Information

๐Ÿ“–

The Treasure Box Story

Imagine you have a treasure box with a label on it. You can put something inside (like your favorite toy's name) and later open the box to see what's inside!

In Python, we call these boxes "variables"โ€”they store information for us!

๐ŸŽ“ Concept: Variables

A variable is like a labeled box that holds information.

# This is how we create a variable (treasure box) chatbot_name = "Noor" # Put "Noor" in the box labeled "chatbot_name" age = 10 # Put the number 10 in the box labeled "age" is_kind = True # Put True (yes) in the box labeled "is_kind"

๐ŸŽ“ Concept: Print (Showing Messages)

To show a message on screen, we use print()โ€”it's like asking the computer to speak!

# Tell the computer to say hello! print("As-salamu alaykum!") print("My name is", chatbot_name) # Show the treasure from our box!
Kids Activity #1: Create Your Own Variables

Task: Everyone creates 3 variables about themselves:

  • my_name = your name
  • my_age = your age
  • favorite_subject = what you love to learn

Then: Use print() to show these on screen!

๐ŸŽค Part 2

Input & If/Else: Asking Questions & Making Decisions

๐Ÿ“–

The Smart Robot Story

Imagine you meet a friendly robot. The robot asks: "What is your name?" You tell it, and the robot remembers!

Then the robot says: "If your name starts with 'A', I'll call you Amazing!"

This is exactly what input() and if/else do in Python!

๐ŸŽ“ Concept: Input (Asking Questions)

input() lets your program ask the user a question and wait for an answer!

# Ask the user their name and store it in a variable user_name = input("What is your name? ") print("Nice to meet you,", user_name, "!")

๐ŸŽ“ Concept: If/Else (Making Decisions)

Sometimes we want our program to do different things based on the answer. That's where if/else comes in!

# Ask a question feeling = input("How are you feeling? (happy/sad) ") # Make a decision based on the answer if feeling == "happy": print("Alhamdulillah! I'm happy too! ๐Ÿ˜Š") elif feeling == "sad": print("Don't worry! Allah is always with you. ๐Ÿคฒ") else: print("I hope you have a blessed day!")
Teacher Tip

Act out if/else with kids! Say: "If you're wearing blue, stand up. Else, sit down." This shows decision-making in action!

Kids Activity #2: Build a Greeting Bot

Task: Create a simple program that:

  1. Asks: "What time is it? (morning/afternoon/evening)"
  2. If morning โ†’ says "Good morning! Start your day with Bismillah!"
  3. If afternoon โ†’ says "Good afternoon! Hope your day is blessed!"
  4. If evening โ†’ says "Good evening! Don't forget your evening dua!"

๐ŸŽ‰ Checkpoint #2

Wow! Your programs can now talk AND think! You're becoming real coders! ๐Ÿ’ช

๐Ÿ“š Part 3

Lists: Storing Many Things at Once

๐Ÿ“– The Backpack Story

Imagine your school backpack. Instead of carrying one pencil, you carry a list of items: pencil, eraser, notebook, snack!

In Python, a list is like a backpackโ€”it holds many items in one place!

๐ŸŽ“ Concept: Lists

A list stores multiple items in order. We use square brackets [ ] to create them.

# Create a list of duas (prayers) duas = ["Bismillah", "Alhamdulillah", "SubhanAllah"] # Access items by their position (counting starts at 0!) print(duas[0]) # Shows "Bismillah" (first item) print(duas[1]) # Shows "Alhamdulillah" (second item) # Add a new item to the list duas.append("MashaAllah") print(duas) # Shows all 4 duas!
Teacher Tip

Use flashcards arranged in a row to demonstrate lists! Number them 0, 1, 2, 3 to show how Python counts from zero.

๐ŸŽ“ Why Lists Are Perfect for Chatbots

Our chatbot needs to remember MANY questions and answers! Lists help us organize them like flashcards.

# Store questions and answers together! questions = ["Who created us?", "What do we say before eating?"] answers = ["Allah created us", "We say Bismillah"] # When someone asks question 0, give answer 0! print("Q:", questions[0]) print("A:", answers[0])
Kids Activity #3: Create Your Q&A List

Task: Create two lists:

  • my_questions = 3 Islamic questions kids ask
  • my_answers = 3 kind, simple answers

Example:

  • Q: "How many times do we pray?" โ†’ A: "We pray 5 times a day!"

๐ŸŽ‰ Checkpoint #3

You're ready! Now you know ALL the Python basics to build a chatbot! Let's do this! ๐Ÿš€

๐Ÿค– Build Time!

Building "Noor" - Our Islamic Chatbot

Time to put everything together! We'll build our chatbot step by step. Follow along and type the code with us!

Step 1: Welcome Message

First, let's make our chatbot introduce itself!

# Step 1: Welcome the user print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—") print("โ•‘ As-salamu alaykum! ๐ŸŒ™ โ•‘") print("โ•‘ I am Noor, your kind โ•‘") print("โ•‘ Islamic helper chatbot! โ•‘") print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•") print()
Teacher Tip

Ask a volunteer to read the welcome message out loud! Make it fun and engaging. Encourage kids to customize their chatbot's name.

Step 2: Get the User's Name

Let's ask who we're talking to!

# Step 2: Get user's name user_name = input("What is your name? ") print("Nice to meet you,", user_name, "! ๐Ÿ˜Š") print()

Step 3: Store Q&A Pairs

Now we create our knowledge baseโ€”the questions Noor knows about!

# Step 3: Create our Q&A database using lists questions = [ "who created us", "how many times do we pray", "what do we say before eating", "what is the quran", "how should we treat others" ] answers = [ "Allah (SWT) created us and everything in the universe! โ˜๏ธ", "We pray 5 times a day: Fajr, Dhuhr, Asr, Maghrib, and Isha! ๐Ÿ•Œ", "We say 'Bismillah' (In the name of Allah) before eating! ๐ŸŽ", "The Quran is Allah's beautiful message to guide us in life! ๐Ÿ“–", "We should treat everyone with kindness, respect, and love! โค๏ธ" ]
Volunteer Moment!

Ask 2-3 kids to suggest more questions and answers! Add them to the lists together as a group.

Step 4: The Chatbot Loop

This is the brain! Our chatbot will keep asking what the user wants to know.

# Step 4: Main chatbot conversation loop print("You can ask me anything about Islam!") print("Type 'bye' when you want to leave.\n") while True: # Get user's question user_question = input(user_name + ": ").lower() # Convert to lowercase # Check if user wants to exit if user_question == "bye": print("Noor: Wa alaykumu as-salam! May Allah bless you! ๐Ÿคฒ") break # Exit the loop # Search for the answer found_answer = False for i in range(len(questions)): if questions[i] in user_question: print("Noor:", answers[i]) found_answer = True break # If we don't know the answer if not found_answer: print("Noor: I'm still learning! Can you ask in a simpler way? ๐Ÿค”") print() # Add spacing for readability
Teacher Tip

Explain the loop: "This is like a conversation that keeps going until we say 'bye'โ€”just like talking with a friend!" Walk through the logic slowly, one line at a time.

๐ŸŽฏ The Complete Chatbot Code

Here's everything put together! This is the full working chatbot:

# ================================================ # NOOR - My Kind Islamic Chatbot # Created by: [Student's Name] # Date: February 7, 2026 # ================================================ # Welcome message print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—") print("โ•‘ As-salamu alaykum! ๐ŸŒ™ โ•‘") print("โ•‘ I am Noor, your kind โ•‘") print("โ•‘ Islamic helper chatbot! โ•‘") print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•") print() # Get user's name user_name = input("What is your name? ") print("Nice to meet you,", user_name, "! ๐Ÿ˜Š\n") # Knowledge base: Questions and Answers questions = [ "who created us", "how many times do we pray", "what do we say before eating", "what is the quran", "how should we treat others", "what is ramadan", "who is prophet muhammad" ] answers = [ "Allah (SWT) created us and everything in the universe! โ˜๏ธ", "We pray 5 times a day: Fajr, Dhuhr, Asr, Maghrib, and Isha! ๐Ÿ•Œ", "We say 'Bismillah' (In the name of Allah) before eating! ๐ŸŽ", "The Quran is Allah's beautiful message to guide us in life! ๐Ÿ“–", "We should treat everyone with kindness, respect, and love! โค๏ธ", "Ramadan is the blessed month when we fast from dawn to sunset! ๐ŸŒ™", "Prophet Muhammad ๏ทบ is the last messenger of Allah and our role model! โœจ" ] # Main conversation loop print("You can ask me anything about Islam!") print("Type 'bye' when you want to leave.\n") while True: # Get user's question user_question = input(user_name + ": ").lower() # Check if user wants to exit if user_question == "bye": print("Noor: Wa alaykumu as-salam! May Allah bless you! ๐Ÿคฒ") break # Search for the answer in our knowledge base found_answer = False for i in range(len(questions)): if questions[i] in user_question: print("Noor:", answers[i]) found_answer = True break # If we don't know the answer if not found_answer: print("Noor: I'm still learning! Can you ask in a simpler way? ๐Ÿค”") print() print("Thank you for chatting with me, " + user_name + "! ๐Ÿ’š")

๐ŸŽ‰ You Did It!

YOU JUST BUILT A REAL CHATBOT! Time to test it! ๐Ÿš€

๐Ÿงช Testing Time

Running & Testing Our Chatbot

How to Run Your Chatbot

  1. Save your code as noor_chatbot.py
  2. Open your terminal or command prompt
  3. Type: python noor_chatbot.py
  4. Press Enter and watch the magic! โœจ

Test These Questions

Try Asking Noor:
  • "Who created us?"
  • "How many times do we pray?"
  • "What is Ramadan?"
  • "Tell me about Prophet Muhammad"
  • "What happens when I ask something Noor doesn't know?"
Teacher Tip

Group Activity: Have kids pair up and test each other's chatbots! One asks questions while the other demonstrates. Celebrate when the chatbot responds correctly!

๐Ÿ› What If Something Goes Wrong?

Don't worry! Every coder faces errors. Here's how to fix common ones:

Common Fixes
  • IndentationError: Check your spacing! Python uses spaces to group code.
  • NameError: Did you spell your variable name correctly?
  • SyntaxError: Did you forget a quote mark (") or colon (:)?
  • Chatbot doesn't respond: Make sure your question matches words in the questions list!
๐Ÿš€ Level Up!

How to Make Your Chatbot Even Better

Now that you have a working chatbot, here are fun ways to extend it!

๐Ÿ’ก Extension Idea #1: Add More Q&A

# Just add more items to your lists! questions.append("what are the five pillars") answers.append("The five pillars are: Shahada, Salah, Zakat, Sawm, and Hajj! ๐Ÿ•‹")

๐Ÿ’ก Extension Idea #2: Add Greetings

# Respond to greetings! if "assalam" in user_question or "salam" in user_question: print("Noor: Wa alaykumu as-salam! How can I help you today? ๐Ÿ˜Š")

๐Ÿ’ก Extension Idea #3: Add Stories

# Tell a beautiful Islamic story! if "story" in user_question: print("Noor: Let me tell you about Prophet Yunus (Jonah)...") print("He was swallowed by a big fish, but never stopped praying!") print("Allah saved him because he always had faith! ๐Ÿ‹")

๐Ÿ’ก Extension Idea #4: Add Daily Duas

# Suggest a dua based on the situation if "morning" in user_question: print("Noor: Morning dua: Alhamdulillah for this new day! โ˜€๏ธ") elif "sleep" in user_question: print("Noor: Before sleep, say: Bismika Allahumma ahya wa amut ๐ŸŒ™")

๐Ÿ’ก Extension Idea #5: Emoji Mood

Make Noor show different moods based on the topic!

# Add emotions to responses happy_emojis = ["๐Ÿ˜Š", "๐Ÿ˜„", "๐ŸŒŸ", "โœจ"] peaceful_emojis = ["๐Ÿ•Œ", "๐ŸŒ™", "โ˜ฎ๏ธ", "๐Ÿคฒ"] # Use them in responses! print("Noor: MashaAllah!", happy_emojis[0])
Challenge for Home

Try adding 3 of these extensions to your chatbot this week! Bring it back to Session 4 to share!

๐Ÿ›ก๏ธ Safety First

Chatbot Best Practices - Being Responsible Coders

โœ… What Our Chatbot SHOULD Do

  • โœ… Use kind, respectful language
  • โœ… Give accurate Islamic information (verified by adults)
  • โœ… Say "I don't know" instead of guessing
  • โœ… Encourage learning and curiosity
  • โœ… Respect all people regardless of background

โŒ What Our Chatbot Should NOT Do

  • โŒ Share personal information (addresses, phone numbers)
  • โŒ Give medical or legal advice
  • โŒ Make fun of anyone or any belief
  • โŒ Discuss adult topics
  • โŒ Pretend to be a real scholar (we're learning!)

๐Ÿ›ก๏ธ The Safety Shield

Remember: Our chatbot is a learning tool, not a replacement for parents, teachers, or scholars!

If someone asks something inappropriate, our chatbot should say:

"I'm a learning chatbot for kids! Please ask a parent, teacher, or trusted adult about this question. ๐Ÿคฒ"

Adding a Safety Check

# List of topics we shouldn't discuss unsafe_topics = ["password", "address", "phone", "credit card"] # Check if question contains unsafe words for unsafe_word in unsafe_topics: if unsafe_word in user_question: print("Noor: That's private information! Never share it online. ๐Ÿ›ก๏ธ") continue # Skip to next question
๐Ÿ“ Mini Recap

What We Learned Today - AI Superhero Skills Unlocked!

๐ŸŽฏ Today's Big Wins

  • ๐Ÿ Met Python - The friendly programming language
  • ๐Ÿ“ฆ Variables - Treasure boxes that store information
  • ๐Ÿ–จ๏ธ Print - Making the computer talk
  • ๐ŸŽค Input - Asking questions and getting answers
  • ๐Ÿค” If/Else - Making smart decisions
  • ๐Ÿ“š Lists - Storing many things in a backpack
  • ๐Ÿค– Built Noor - A real working Islamic chatbot!
  • ๐Ÿ›ก๏ธ Safety First - Being responsible coders

๐Ÿ—ฃ๏ธ Tell Someone at Home

Homework Challenge

Teach your parent or sibling about:

  1. What a variable is (use the treasure box story!)
  2. How if/else works (use the robot story!)
  3. Show them your chatbot in action! ๐ŸŽ‰

๐ŸŒŸ You Are Now:

  • โœ… A Python programmer
  • โœ… A chatbot builder
  • โœ… A problem solver
  • โœ… An AI Superhero who codes with Islamic values!
๐Ÿ”ฎ What's Next?

Future Adventures - Session 4 Preview

๐Ÿš€ Where We're Going Next

In our next session, we'll learn about:

  • ๐Ÿง  Making Noor Smarter - Adding AI/ML concepts
  • ๐ŸŽจ Adding a Voice - Text-to-speech for our chatbot
  • ๐ŸŽฏ Pattern Matching - Understanding questions better
  • ๐Ÿ’พ Saving Data - Remembering past conversations
  • ๐ŸŒ Local LLMs - Introduction to on-premise AI models

๐Ÿ“š Practice at Home

Weekly Coding Challenge

Your Mission:

  1. Add 5 new Q&A pairs to your chatbot
  2. Teach Noor to tell one Islamic story
  3. Add a greeting and goodbye message
  4. Test your chatbot with 3 different people
  5. Write down what questions Noor struggled with

Bonus: Draw a flowchart showing how your chatbot thinks!

๐ŸŽ“ Keep Learning Resources

  • ๐Ÿ“– Python.org - Free tutorials for kids
  • ๐ŸŽฎ Code.org - Fun coding games
  • ๐Ÿ“บ Islamic Kids Programs - Learn Quran & Hadith facts to add to Noor
  • ๐Ÿ‘ฅ Our Online Community - Share your chatbot with other AI Superheroes!

๐ŸŽ‰ CONGRATULATIONS, CODE WARRIORS! ๐ŸŽ‰

You didn't just learn Python todayโ€”you built something real that can help others learn about Islam!

You are officially AI SUPERHERO CODERS! ๐Ÿ’ช๐Ÿฆธโ€โ™€๏ธ๐Ÿฆธโ€โ™‚๏ธ

Keep coding, keep learning, keep being awesome! ๐ŸŒŸ

"Indeed, Allah loves those who are constantly striving to improve." - Inspired by Islamic teachings

๐Ÿ“ธ Share Your Journey!

Take a screenshot of your chatbot running and share it with your family! Don't forget to explain how it works using the stories we learned today! ๐Ÿ’š

Back to Blog