[v๊ธฐ์ด-๋ ผ๋ฆฌ์ฐ์ฐ.6052~6058]CodeUp_Python ๊ธฐ์ด 100์
211223 ์์ฑ
<๋ณธ ๋ธ๋ก๊ทธ๋ CodeUp ์ ์ฐธ๊ณ ํด์ ์ ๋ง์ ํ์ด๋ฅผ ์์ฑํ์์ต๋๋ค>
6052
์ ์ ์ ๋ ฅ๋ฐ์ ์ฐธ ๊ฑฐ์ง ํ๊ฐํ๊ธฐ(์ค๋ช )
๋ด ํ์ด
a = int(input())
print(bool(a))
bool( ) ์ ์ด์ฉํ๋ฉด ์ ๋ ฅ๋ ์์ด๋ ๊ฐ์ ํ๊ฐํด ๋ถ ํ์ ๊ฐ(True ๋๋ False)์ ์ถ๋ ฅ
์ ์๊ฐ 0์ False(๊ฑฐ์ง)๋ก ํ๊ฐ๋๊ณ , ๊ทธ ์ธ์ ๊ฐ๋ค์ ๋ชจ๋ True(์ฐธ)
6053
์ฐธ ๊ฑฐ์ง ๋ฐ๊พธ๊ธฐ(์ค๋ช )
(์ ๋ ฅ๋ ์ ์์ ๋ถ ๊ฐ์ด False ์ด๋ฉด True, True ์ด๋ฉด False ๋ฅผ ์ถ๋ ฅ)
๋ด ํ์ด
a = bool(int(input()))
print(not a)
6054
๋ ๋ค ์ฐธ์ผ ๊ฒฝ์ฐ๋ง ์ฐธ ์ถ๋ ฅํ๊ธฐ(์ค๋ช )
๋ด ํ์ด
a, b = input().split()
print(bool(int(a)) and bool(int(b)))
AND ์ฐ์ฐ(boolean AND)์ด๋ผ๊ณ ๋ ๋ถ๋ฅด๊ณ , · ์ผ๋ก ํ์ํ๊ฑฐ๋ ์๋ต
์งํฉ ๊ธฐํธ ∩(๊ต์งํฉ, intersection)๋ก ํ์
๋ถ ๊ฐ๋ค ์ฌ์ด์ ๋ ผ๋ฆฌ(not, and, or)
6055
ํ๋๋ผ๋ ์ฐธ์ด๋ฉด ์ฐธ ์ถ๋ ฅํ๊ธฐ (์ค๋ช )
๋ด ํ์ด
a, b = input().split()
print(bool(int(a)) or bool(int(b)))
OR ์ฐ์ฐ(boolean OR)์ด๋ผ๊ณ ๋ ๋ถ๋ฅด๊ณ , + ๋ก ํ์ํ๊ฑฐ๋, ์งํฉ ๊ธฐํธ ∪
6056
์ฐธ/๊ฑฐ์ง์ด ์๋ก ๋ค๋ฅผ ๋์๋ง ์ฐธ ์ถ๋ ฅํ๊ธฐ(์ค๋ช )
๋ด ํ์ด
a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print((a and (not b)) or ((not a) and b))
์ฐธ ๊ฑฐ์ง์ด ์๋ก ๋ค๋ฅผ ๋์๋ง True ๋ก ๊ณ์ฐํ๋ ๋ ผ๋ฆฌ์ฐ์ฐ์ XOR(exclusive or, ๋ฐฐํ์ ๋ ผ๋ฆฌํฉ)
6057
์ฐธ/๊ฑฐ์ง์ด ์๋ก ๊ฐ์ ๋์๋ง ์ฐธ ์ถ๋ ฅํ๊ธฐ(์ค๋ช )
๋ด ํ์ด
a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print(((not a) and (not b)) or (a and b))
6058
๋ ๋ค ๊ฑฐ์ง์ผ ๊ฒฝ์ฐ๋ง ์ถ๋ ฅํ๊ธฐ
๋ด ํ์ด
a, b = input().split()
a = bool(int(a))
b = bool(int(b))
print(((not a) and (not b)) or not(a or b))
