티스토리 뷰

Python

Operator

techbard 2016. 6. 6. 14:36

# compare operator


x = [1, 2]

y = [1, 2]


# equality operator

print(x == y)

# identity operator

print(x is y)


# 결과

True

False


a = 2

b = 2


print(a == b)

print(a is b)


# 결과
True
True

o = 'b' > 'a'
print(o)

# 결과
True

o = [1, 2] > [2, 1]
print(o)

o = [4, 1] > [3, 1]
print(o)

o = [1, [2, 3]] > [1, [2, 4]]
print(o)

o = [1, [2, 10]] > [1, [2, 9]]
print(o)

# 결과
False
True
False
True


댓글
댓글쓰기 폼
공지사항
Total
411,812
Today
1
Yesterday
14
«   2020/01   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
글 보관함