ประเภทข้อมูลใน Python
Jason Myers
Instructor
TrueFalseสังเกตการพิมพ์ตัวพิมพ์ใหญ่ เพราะอาจทำให้สับสนเมื่อสลับระหว่าง Python กับภาษาอื่น
out_of_cookies = True
if out_of_cookies:
print("Run to the store NOW!")
Run to the store NOW!
apples=2
if apples:
print("We have apples.")
"We have apples."
apples=0
if apple:
print('We have apples.')
1"Cookies"["Cake", "Pie"]{"key": "value"}0""[]{}Nonecookie_qty == 3
== เท่ากับ!= ไม่เท่ากับ< น้อยกว่า<= น้อยกว่าหรือเท่ากับ> มากกว่า>= มากกว่าหรือเท่ากับx = 0.1 + 1.1
x == 1.2
False
print(x)
1.2000000000000002
ระวังการเปรียบเทียบค่าเท่ากับในชนิดข้อมูล float!
ประเภทข้อมูลใน Python