🐱 Cheer Me Up
✍️ Coded line by line by Nutpoom Sookkasem, age 16 💛 · See full profile and all works →
📖 What is this project?
Cheer Me Up คือโปรแกรมเล็ก ๆ ที่อบอุ่นหัวใจ — เปิดมาถามว่า “วันนี้เหนื่อยหรือเปล่า?” ถ้าตอบว่าใช่ จะให้เลือก 3 ทาง: อยากได้คำปลอบใจ อยากได้คำคมสร้างแรงบันดาลใจ (สุ่มจากคลัง 10 ประโยคที่นักเรียนคัดมาเอง) หรืออยากดูรูปแมวน่ารัก ๆ ซึ่งโปรแกรมจะสั่งเปิดเว็บเบราว์เซอร์ขึ้นมาให้เลย
ผลงานชิ้นนี้แสดงให้เห็นว่านักเรียนเข้าใจการใช้ webbrowser สั่งงานโปรแกรมอื่นจาก Python ได้ และที่สำคัญกว่านั้น — นักเรียนคิดถึงความรู้สึกของคนใช้ ไม่ใช่แค่เขียนโค้ดให้ทำงานได้ ซึ่งเป็นหัวใจของการออกแบบซอฟต์แวร์ที่ดี
🕹️ Try the real thing!
This is the real program, converted to run on the web with every rule kept exactly the same — type your answer and press Enter, just like running it in Python.
👨💻 The original Python source code (with the comments they wrote themselves)
import random
import webbrowser as wb
#ใส่ข้อมูลใส่ array
quotes = ["You didn’t come this far to stop now.", "Ignore the sheep. Be the lion.", "Flow like water. Adapt.", "No darkness, no stars.", "Small wins build empires.", "Big things start small.", "Pressure makes diamonds.", "Win or learn. No losing.", "Fear kills more dreams than failure.", "Legends are built, not born."]
cats = ["https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Y3V0ZSUyMGNhdHxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&q=80&w=1000", "https://i.pinimg.com/originals/b6/a6/d5/b6a6d50de7eb36065b98ebd254d46cd5.jpg", "https://www.publicdomainpictures.net/pictures/160000/velka/mignon-petit-chaton.jpg", "https://tse3.mm.bing.net/th?id=OIP.X3mfeI7lW-x1NvHx8AZwAAHaHa&pid=Api"]
def inspri():#กำหนด function inspri
ins = random.choice(quotes)
return ins
def catpic():#กำหนด function catpic
cat = random.choice(cats)
return cat
a = input("Are you a bit own today?: ").lower()#ถามหาข้อมูลจากผู้ใช้
if a in ["yes", "y"]:#ตรวจสอบข้อมูลว่าได้รับค่า "yes" หรือ ค่า "y" มาหรือไม่
a = input("Do you want me to comfort you? or you want some insprirational quote? or just some cat pic would be fine?(1, 2, 3): ")#รับค่าจากผู้ใช้
if a == "1":#ตรวจสอบข้อมูลว่าได้รับค่า "1" มาหรือไม่
print("hope you get well soon bad thing will soon pass")
elif a == "2":#ตรวจสอบข้อมูลว่าได้รับค่า "2" มาหรือไม่
print(inspri())
elif a == "3":#ตรวจสอบข้อมูลว่าได้รับค่า "3" มาหรือไม่
wb.open(catpic())
else:
print("well see you later man")
Our Python course is taught live, one-on-one, and every child builds a real project of their own just like these.