number
, string
, tuple
list
, dict
, set
a = [1, 2, 3] # list
b = [1, 2, 3] # list
print("a: ", a)
print("b: ", b)
print("a == b ", a == b)
print("a is b ", a is b)
a: [1, 2, 3] b: [1, 2, 3] a == b True a is b False
c = "abc"
d = "abc"
print("c: ", c)
print("d: ", d)
print("c == d ", c == d)
print("c is d ", c is d)
c: abc d: abc c == d True c is d True
str
for python3 is unicode while it's byte code for python2¶# method 1
Tom = {"name": "Tom", "age": 40, "gender": "male"}
# method 2
Tom = dict(name="Tom", age=40, gender="male")
# method 3
Tom = dict(zip(["Tom", "age", "gender"], ["Tom", 40, "male"]))
if not "habit" in Tom:
print("We don't know Tom's habit.")
We don't know Tom's habit.