การแสดงผลข้อมูลด้วยคำสั่ง print นักเรียนสามารถแสดงผลข้อมูลโดยใช้คำสั่ง print ได้ดังนี้
ตัวอย่างโค้ดโปรแกรม 1
number = 50 gpa = 3.80 name = "Nida" surname = "Chuapratoom" print(number) print("My gpa is ",gpa) print("My name is ",name+" "+surname)
ผลลัพธ์
50 My gpa is 3.8 My name is Nida Chuapratoom
หรือ
number = 50 gpa = 3.80 name = "Nida " surname = "Chuapratoom" print("%d"%number) print("My gpa is %.2f"%gpa) print("My name is %s"%name+" "+surname)
50 My gpa is 3.80 My name is Nida Chuapratoom
........................................................................
money = 1000 price1 = 250.70 price2 = 490.99 customer = "SKR" print("My name is."%customer) print("I have ",," baht.") print("My bag is"%price1," baht.") print("My glass is %.2f"," baht.")