Your first program · โปรแกรมแรกของคุณ
Welcome
- Python follows your instructions, one line at a time.
- You write code here and run it — nothing to install.
- Read each step, then press Continue.
ยินดีต้อนรับ
- Python遵循 คำสั่ง ของคุณ บรรทัดต่อบรรทัด
- คุณเขียนโค้ดที่นี่และรันมัน ไม่ต้องติดตั้งอะไรทั้งนั้น
- อ่านแต่ละขั้นตอน แล้วกด ดำเนินการต่อ
Show text with print
print(...)shows text on the screen.- Put the text in quotes:
"...". - Each
printstarts a new line.
แสดงข้อความด้วย print
print(...)แสดงข้อความบนหน้าจอ- วางข้อความในเครื่องหมายคำพูด:
"..." - แต่ละ
printเริ่ม บรรทัดใหม่
print("Welcome to Python!")
print("This line runs next.")
Strings
- Text in quotes is called a string.
- You can use double quotes
"..."or single quotes'...'. - You can also print a number with no quotes, like
print(42).
สตริง (ข้อความ)
- ข้อความในเครื่องหมายคำพูดเรียกว่า สตริง
- คุณสามารถใช้เครื่องหมายคำพูดคู่
"..."หรือเครื่องหมายคำพูดเดี่ยว'...' - คุณยังสามารถพิมพ์ จำนวน โดยไม่มีเครื่องหมายคำพูด เช่น
print(42)
Comments
- A line that starts with
#is a comment. - Python ignores comments — they do not run.
- Use them to leave notes for people who read your code.
_heading
- บรรทัดที่ขึ้นต้นด้วย
#เป็น _heading - Python ข้าม heading — มันไม่ถูกรัน
- ใช้เพื่อทิ้งหมายเหตุสำหรับผู้ที่อ่านโค้ดของคุณ
# This line is a note for people. Python skips it.
print("Comments do not show.")
Common mistakes
printneeds quotes around text:print("Hi"), notprint(Hi).- Python is case-sensitive:
Printis not the same asprint.
ข้อผิดพลาดที่พบบ่อย
printต้องการเครื่องหมายคำพูดรอบข้อความ:print("Hi")ไม่ใช่print(Hi)- Python แยกตัวพิมพ์ใหญ่-เล็ก:
Printไม่เหมือนกันกับprint
Now you try
- Below are a few tasks. Type your code and press Run.
- Press Check answer to see if it is correct.
ลองดูเลย
- ด้านล่างมีงาน一些小ๆ พิมพ์โค้ดของคุณแล้วกด รัน
- กด ตรวจสอบคำตอบ เพื่อดูว่าถูกต้องหรือไม่
How a program runs · การทำงานของโปรแกรม
A program runs top to bottom, one statement at a time. · โปรแกรมทำงานจาก บนลงล่าง บรรทัดละหนึ่งบรรทัด
Use print(...) to make Python show the words Hello, world! exactly (same spelling, same punctuation). · ใช้ print(...) เพื่อให้ Python แสดงข้อความ Hello, world! พอดี (สะกดคำและเครื่องหมายวรรคตอนเหมือนกัน)
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
Print two lines. The first line must be My name is Pat. The second line must be I am learning Python. (Use two print(...) calls.) · พิมพ์ สอง บรรทัด บรรทัดแรกต้องเป็น My name is Pat บรรทัดที่สองต้องเป็น I am learning Python (ใช้การเรียก print(...) สองครั้ง)
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
Keep the comment line, then print the number 42. Notice the comment never appears in the output. · คงบรรทัดคอมเมนต์ไว้ แล้ว print ตัวเลข 42 หมายเหตุว่าคอมเมนต์จะไม่ปรากฏในผลลัพธ์
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
Print a box made of three lines: first +-----+, then | Hi! |, then +-----+ again. · พิมพ์กล่องที่ประกอบด้วยสามบรรทัด: ขั้นแรก +-----+, ต่อด้วย | Hi! |, แล้ว +-----+ อีกครั้ง
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่