[Python] 조건문

#조건문

a=1

b=2

c=3

d=4

s=”show me the money” 

x=[1,2]

y=[1,2]

if a < b:

    print “bbbb”

elif b < a:

    print “aaaa”

else:

    print “aabb”

if a < b and b < c and not (d < c):

    print “dddd”

if “money” in s: # 좌측 문자열이 우측 문자열 또는 객체에 포함되어있는지 확인

    print “money in string”

if x is y:      #동일한 객체인지 비교

    print “x and y is same object”

if x == y:      #객체의 값이 같은지 비교

    print “x’s value and y’s value is same”

if type(x) is type(y): #객체의 타입이 같은지 비교 

    print “x and y is same type”

댓글 남기기

바로가기