myName = input("Please enter your name: ")
myAge = input("What about your age: ")
print ("Hello World, my name is", myName, "and I am", myAge, "years old.")
Please enter your name:
What about your age:
Hello World, my name is กฤษณ์ and I am 20 years old.
myAge = input("Hi %s, what about your age: " %(myName))
myAge = input("Hi {}, what about your age: ".format(myName))
print ("Hello World, my name is", myName, "and I am", myAge, "years old.")
print ("Hello World, my name is %s and I am %s years old." %(myName, myAge))
%s ข้อความ
%d เลขจำนวนเต็ม
%f เลขจำนวนทศนิยม
print ("Hello World, my name is {} and I am {} years old".format(myName, myAge))
print (f"Hello World, my name is {myName} and I am {myAge} years old")
print ('''Hello World.
My name is James and
I am 20 years old.''')
Hello World.
My name is James and
I am 20 years old.
print ('ข้อมูลส่วนตัวของท่าน')
print ('ชื่อ\tกฤษณ์ ท.')
print ('ที่ทำงาน\tวท.ศรีวรการ')
ข้อมูลส่วนตัวของท่าน
ชื่อ กฤษณ์ ท.
ที่ทำงาน วท.ศรีวรการ
print ('ข้อมูลส่วนตัวของท่าน')
print ('ชื่อ\tกฤษณ์ ท.\nที่ทำงาน\tวท.ศรีวรการ')
ข้อมูลส่วนตัวของท่าน
ชื่อ กฤษณ์ ท.
ที่ทำงาน วท.ศรีวรการ
print ('\\ข้อมูลส่วนตัวของท่าน\\')
\ข้อมูลส่วนตัวของท่าน\
print ("I am 5'9\" tall")
I am 5'9" tall
print ('I am 5\'9" tall')
I am 5'9" tall
Aj. Krit Th.
https://www.kritth.com