← Home
Loading Python runtime…
solution.py
Python runtime is loading. Please wait…

Run tests to see results here.

📁

Drag & drop files here or

CSV, JSON, TXT, images — stored in browser memory for your Python code

Uploaded files are available at /data/<filename> inside Python (e.g. pd.read_csv('/data/sales.csv')).

Uploaded Files 0

  • No files uploaded yet.

Preview

Select a file to preview its contents.

คู่มือการใช้งาน MegaCode

การเริ่มต้น

  • เลือกโจทย์: คลิกปุ่ม "🎲 New Task" เพื่อรับโจทย์ใหม่
  • อ่านโจทย์: อ่านคำอธิบายและตัวอย่างผลลัพธ์ให้เข้าใจ
  • เขียนโค้ด: เขียนโค้ด Python ตรง ๆ ใช้ print() แสดงผลลัพธ์

การรันโค้ด

  • Run: คลิกปุ่ม "▶ Run" เพื่อรันโค้ดและดูผลลัพธ์ที่พิมพ์ออกมา
  • Run Tests: คลิกปุ่ม "✓ Run Tests" เพื่อตรวจสอบคำตอบ (ระบบจะดูจาก output ที่พิมพ์)
  • Reset: คลิกปุ่ม "↺ Reset" เพื่อรีเซ็ตโค้ดเริ่มต้น

การเขียนโค้ดแบบพิมพ์ผลลัพธ์

  • ไม่ต้องสร้างฟังก์ชัน: แค่เขียนโค้ดตรง ๆ แล้วใช้ print()
  • การย่อหน้า: 4 ช่องว่าง (มาตรฐาน Python) เฉพาะในลูป/เงื่อนไข

ตัวอย่างที่ถูกต้อง

mass = 10
velocity = 20
ke = 0.5 * mass * velocity**2
print(f"Kinetic energy: {ke:.2f} J")  # ✅ พิมพ์ผลลัพธ์

ตัวอย่างที่ผิด

def kinetic_energy():
    mass = 10
    velocity = 20
    ke = 0.5 * mass * velocity**2
    return ke  # ❌ ใช้ return แทน print
id="tab-errors">

ข้อผิดพลาดที่พบบ่อย

  • ลืมใช้ print() - ต้องพิมพ์ผลลัพธ์ด้วย print เสมอ
  • ใช้ return แทน print - ระบบตรวจจาก output ที่พิมพ์ออกมา
  • ค่าไม่ถูกต้อง - ตรวจสอบค่าตัวแปรและการคำนวณอีกครั้ง
  • การย่อหน้าไม่ถูกต้อง - ใช้ 4 ช่องว่างตามมาตรฐาน
  • ลืม import - ถ้าใช้ math ต้อง import math

Tips & Tricks

  • ✅ ใช้ input() เพื่อรับค่าจากผู้ใช้ (จะแสดง popup ใน browser)
  • ✅ ใช้ print() เพื่อแสดงผลลัพธ์
  • ✅ ตรวจสอบว่าคำนวณค่าถูกต้องตามโจทย์
  • ✅ ตรวจสอบรูปแบบ output ให้ตรงตามตัวอย่าง
  • ✅ ตรวจสอบชื่อตัวแปรและการสะกดคำ