จงเขียนโปรแกรมให้แสดงข้อความต่อไปนี้ออกทางหน้าจอ:
css
CopyEdit
Hello, Python!
I love coding.
<details> <summary>เฉลย</summary>
python
CopyEdit
print("Hello, Python!")
print("I love coding.")
</details>
จงแสดงข้อความดังนี้ให้อยู่ในบรรทัดเดียวกัน:
css
CopyEdit
Welcome to Python programming!
<details> <summary>เฉลย</summary>
python
CopyEdit
print("Welcome", "to", "Python", "programming!")
</details>
ให้แสดงข้อความนี้ออกมาในหลายบรรทัด (ใช้ \n):
scss
CopyEdit
Line 1
Line 2
Line 3
<details> <summary>เฉลย</summary>
python
CopyEdit
print("Line 1\nLine 2\nLine 3")
</details>
จงเขียนโปรแกรมให้แสดงผลลัพธ์นี้:
arduino
CopyEdit
My favorite word is "Python"
<details> <summary>เฉลย</summary>
python
CopyEdit
print('My favorite word is "Python"')
</details>
จงแสดงผลลัพธ์ของการคำนวณ 5 × 7 โดยใช้ print()
csharp
CopyEdit
The result is: 35
<details> <summary>เฉลย</summary>
python
CopyEdit
print("The result is:", 5 * 7)
</details>
print("A", "B") จะคั่นคำด้วยช่องว่างโดยอัตโนมัติ
ใช้ \n เพื่อขึ้นบรรทัดใหม่
ใช้ \t เพื่อเว้นวรรคแบบ tab