🌱 Tutorial 1: Ask AI to Write Simple Python Scripts
บทเรียนที่ 1: ให้ AI เขียนสคริปต์ Python ง่ายๆ
Write Simple Scripts with AI — เขียนสคริปต์ง่ายๆ กับ AI 🌱 Easy
สิ่งที่คุณจะได้เรียนรู้:
- วิธีเขียน prompt ให้ AI สร้างโค้ด Python
- การใช้ตัวแปร (variables) และฟังก์ชัน print
- การใช้ first conditional ในการอธิบายโปรแกรม
- การให้ AI อธิบายโค้ดให้เข้าใจง่าย
What You'll Learn:
Ask AI to write simple Python scripts! You'll learn variables, print statements, and how to describe programs using first conditional.
1สร้างโปรแกรมทักทาย — Create a Greeting Program
เริ่มจากโปรแกรมง่ายๆ ที่ถามชื่อผู้ใช้แล้วทักทาย ใช้ first conditional ในการเขียน prompt!
English: Start with a simple program that asks the user's name and greets them. Use first conditional in your prompt!
# Ask user for their name
name = input("What is your name? ")
# Check if name is empty
if name:
print(f"Hello, {name}! Welcome!")
else:
print("Please enter your name.")
2สร้างโปรแกรมคำนวณอายุ — Create an Age Calculator
ลองสร้างโปรแกรมที่คำนวณอายุจากปีเกิด
English: Try creating a program that calculates age from the birth year.
3สร้างโปรแกรมแปลงอุณหภูมิ — Create a Temperature Converter
ให้ AI สร้างโปรแกรมแปลงอุณหภูมิจาก Celsius เป็น Fahrenheit
English: Ask AI to create a temperature converter from Celsius to Fahrenheit.
💡 Writing Good Prompts — เคล็ดลับการเขียน Prompt ที่ดี
Thai: ยิ่ง prompt ชัดเจน ยิ่งได้โค้ดที่ดี! ใช้ first conditional เพื่ออธิบายว่า "ถ้าผู้ใช้ทำ X โปรแกรมจะทำ Y"
English: The clearer your prompt, the better the code! Use first conditional to describe: "If the user does X, the program will do Y."
🐛 Tutorial 2: Debug Code with AI — Find and Fix Errors
บทเรียนที่ 2: ดีบักโค้ดด้วย AI — ค้นหาและแก้ไขข้อผิดพลาด
Debug Code with AI — แก้บั๊กโค้ดด้วย AI 🔍 Medium
สิ่งที่คุณจะได้เรียนรู้:
- วิธีค้นหา error ในโค้ด Python
- วิธีให้ AI ช่วยดีบักโค้ด
- ประเภทข้อผิดพลาด: syntax error, runtime error, logic error
- การใช้ first conditional อธิบายปัญหาและวิธีแก้
What You'll Learn:
Learn to find and fix errors in Python code with AI help! Understand syntax errors, runtime errors, and logic errors.
1ค้นหา Syntax Error — Find Syntax Errors
Syntax error คือข้อผิดพลาดจากการเขียนโค้ดผิดรูปแบบ ลองส่งโค้ดที่มี error ให้ AI ช่วยหา
English: A syntax error happens when code doesn't follow the rules. Send buggy code to AI and ask it to find the errors.
1. Line 1: Missing closing parenthesis
) in input()2. Line 4:
age is a string, can't add integer 1 — need int(age) + 13. Line 5: Can't concatenate string and integer — need
str(next_year)
2แก้ Runtime Error — Fix Runtime Errors
Runtime error เกิดขณะโปรแกรมทำงาน ตัวอย่างเช่น การหารด้วยศูนย์
English: Runtime errors happen while the program runs. For example, dividing by zero.
3แก้ Logic Error — Fix Logic Errors
Logic error คือเมื่อโค้ดทำงานได้แต่ให้ผลลัพธ์ผิด ยากที่สุดในการหา!
English: A logic error is when the code runs but gives the wrong result. These are the hardest to find!
💡 Debugging Tip — เคล็ดลับการดีบัก
Thai: เมื่อพบ error ลองอ่านข้อความ error ก่อน! Python จะบอกบรรทัดที่มีปัญหาและประเภท error ถ้ายังไม่เข้าใจ ค่อยส่งให้ AI
English: When you find an error, read the error message first! Python tells you the line number and error type. If you still don't understand, then ask AI.
🏗️ Tutorial 3: Build a Complete Program with AI
บทเรียนที่ 3: สร้างโปรแกรมเต็มรูปแบบด้วย AI
Build a Quiz App with AI — สร้างแอปถามตอบด้วย AI 🏆 Hard
สิ่งที่คุณจะได้เรียนรู้:
- วิธีสร้างโปรแกรมเต็มรูปแบบด้วย AI ทีละขั้นตอน
- การใช้ functions, loops, และ variables ร่วมกัน
- การใช้ first conditional วางแผนโปรแกรม
- การให้ AI เพิ่มฟีเจอร์ใหม่ทีละขั้น
What You'll Learn:
Build a complete quiz application step by step with AI! Learn to use functions, loops, and variables together.
1วางแผนโปรแกรม — Plan the Program
ก่อนเขียนโค้ด ใช้ first conditional วางแผนว่าโปรแกรมจะทำอะไร
English: Before coding, use first conditional to plan what the program will do.
2ให้ AI สร้างโค้ดหลัก — Have AI Create the Core Code
ส่ง prompt ที่วางแผนไว้ให้ AI แล้วอ่านโค้ดที่ได้ ทำความเข้าใจแต่ละส่วน
English: Send your plan to AI and read the code carefully. Understand each part.
def run_quiz():
questions = [
{"q": "What does HTML stand for?", "a": "hypertext markup language"},
{"q": "What language does AI use most?", "a": "python"},
...
]
score = 0
for item in questions:
answer = input(item["q"] + " ").lower()
if answer == item["a"]:
print("Correct!")
score += 1
else:
print(f"Wrong! Answer: {item['a']}")
print(f"Score: {score}/{len(questions)}")
3เพิ่มฟีเจอร์ — Add Features Step by Step
ให้ AI เพิ่มฟีเจอร์ใหม่ทีละอย่าง
English: Ask AI to add features one at a time.
4ทดสอบและปรับปรุง — Test and Improve
ทดสอบโปรแกรมด้วยตัวเอง ลองใส่ค่าที่ไม่คาดคิด แล้วให้ AI ช่วยแก้ปัญหา
English: Test the program yourself. Try unexpected inputs. Ask AI to help fix any issues.
📝 Grammar Checkpoint — ตรวจสอบไวยากรณ์
ก่อนจะจบ ทบทวน First Conditional อีกครั้ง:
Structure / โครงสร้าง:
✅ If + present simple, will + base verb
✅ Will + base verb + if + present simple (กลับด้านได้)
Coding Examples / ตัวอย่างเกี่ยวกับโค้ด:
✅ If you write clean code, the team will understand it easily.
✅ The program will crash if you don't handle the error.
✅ If the variable is empty, the function will return an error.
❌ If you will write clean code... (Don't use "will" after "if"!)
Practice — Complete these sentences / เติมประโยค:
1. If you debug the code, the program ___. (will work correctly)
2. If the syntax ___ wrong, the code will not compile. (is)
3. You will save time if you ___ AI to write boilerplate. (use)
4. If the loop ___ forever, the program will freeze. (runs)
⭐ Best Practices — แนวปฏิบัติที่ดีสำหรับ AI-Assisted Coding
💡 Tips for AI-Assisted Coding — เคล็ดลับการเขียนโค้ดด้วย AI
- Understand before copying: If you copy without understanding, you will not learn — อ่านและเข้าใจโค้ดก่อนคัดลอก
- Start simple: If you start with small programs, you will build confidence — เริ่มจากโปรแกรมเล็กๆ ก่อน
- Ask AI to explain: "Explain each line" — ขอให้ AI อธิบายทุกบรรทัด
- Test edge cases: If you test unusual inputs, you will find hidden bugs — ลองใส่ค่าผิดปกติเพื่อหาบั๊ก
- Iterate step by step: If you add features one at a time, the code will stay organized — เพิ่มฟีเจอร์ทีละอย่าง
- Use comments: If you add comments, the code will be easier to read later — เขียนคอมเมนต์เสมอ
⚠️ Things to Watch Out For — สิ่งที่ต้องระวัง
- AI can write buggy code: Always test the code before trusting it — ทดสอบโค้ดเสมอ
- AI doesn't know your exact needs: Be specific in your prompts — เขียน prompt ให้ชัดเจน
- Don't skip learning: If you only copy, you will not become a programmer — อย่าแค่ลอก ต้องเรียนรู้ด้วย
- Security matters: If you put passwords in code, hackers will find them — อย่าใส่รหัสผ่านในโค้ด
🏆 เก่งมาก! You've Done Great!
คุณได้ฝึกเขียนโค้ดด้วย AI และ First Conditional แล้ว!
You have practiced AI-assisted coding and first conditional!
ตอนนี้คุณพร้อมทำแบบทดสอบแล้ว!
If you take the exam now, you will do great!