연산자

gyomni·2021년 12월 18일
0

Python

목록 보기
9/12
post-thumbnail

# 관계연산자 ( >, >=, <, <=, ==, != )

a = 10
b = 0

print(a==b) # False
print(a!=b) # True
print(a>b) # True
print(a>=b) # True
print(a<b) # False
print(a<=b) # False

# 참 거짓 종류(True, False)

참 : "내용", [내용], (내용), {내용},1

거짓 : "", [], (), {}, 0

city = ""

if city: 
    print(">>>True")
else:
    print(">>>False")

# >>>False

# 논리 연산자 ( and or not )

a = 100
b = 60
c = 15

print('and :', a > b and b > c) # and : True
print('or : ', a > b or c > b) # or :  True
print('not : ' ,not a > b) # not :  False
print(not False) # True
print(not True) # False

# 산술, 관계, 논리 연산자

=> 산술 > 관계 > 논리 순서로 적용 됨.

print('ex1 :' ,5 + 10 > 0 and not 7+3 ==10) # ex1 : False ( T and F 가 되어 F 출력 )

score1 = 90
score2 = 'A'

if score1 >= 90 and score2 =='A':
    print("합격하셨습니다.")
else:
    print("불합격입니다.")

# 합격하셨습니다.
profile
Front-end developer 👩‍💻✍

0개의 댓글