# 01 흐름(flow)를 따라가세요
def clinic():
print ("You've just entered the clinic!")
print ("Do you take the door on the left or the right?")
answer = input("Type left or right and hit 'Enter'.").lower()
if answer == "left" or answer == "l":
print ("This is the Verbal Abuse Room, you heap of parrot droppings!")
elif answer == "right" or answer == "r":
print ("Of course this is the Argument Room, I've told you that already!")
else:
print ("You didn't pick left or right! Try again.")
clinic()
clinic()
You've just entered the clinic! Do you take the door on the left or the right? Type left or right and hit 'Enter'.right Of course this is the Argument Room, I've told you that already!
17 < (118 %100)
True
# 02 자세히 비교하기!
bool_one = 17 < (118 %100)
print(bool_one)
bool_two = 100 == ((33 * 3) + 1)
print(bool_two)
bool_three = 19 <= 2 ** 4
print(bool_three)
bool_four = -22 >= -18
print(bool_four)
bool_five = 99 != 98 + 1
print(bool_five)
True True False False False
# 03 더 자세히 비교하기!
bool_one = 20 + -10 * 2 > 10 % 3 % 2
bool_two = (10 + 17)**2 == 3**6
bool_three = 1**2**3 <= -(-(-1))
bool_four = 40 / 20 * 4 >= -4**2
bool_five = 100**0.5 != 6 + 4
# 04 불린 연산자(Boolean Operators)
# Make me true!
bool_one = 1 > 0
# Make me false!
bool_two = 2 > 3
# Make me true!
bool_three = 1 == 1
# Make me false!
bool_four = 2 != 2
# Make me true!
bool_five = 2 == 2
# 06 And 연산자
bool_one = False and False
bool_two = -(-(-(-2))) == -2 and 4 >= 16**0.5
bool_three = 19 % 4 != 300 / 10 / 10 and False
bool_four = -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2
bool_five = True and True
# 07 Or 연산자
bool_one = 2**3 == 108 % 100 or 'Cleese' == 'King Arthur'
bool_two = True or False
bool_three = 100**0.5 >= 50 or False
bool_four = True or True
bool_five = 1**100 == 100**1 or 3 * 2 * 1 != 3 + 2 + 1
# 08 Not 연산자
bool_one = False
bool_two = True
bool_three = True
bool_four = True
bool_five = False
# 09 This and That or This But Not That
bool_one = False or not True and True
print(bool_one)
bool_two = False and not True or True
print(bool_two)
bool_three = True and not (False or False)
bool_four = not not True or False and not True
bool_five = False or not (True and True)
False True
# 10 Mix n Match
# Make me false!
bool_one = not True
# Make me true!
bool_two = True and True
# Make me false!
bool_three = False or False
# Make me true!
bool_four = not False
# Make me true!
bool_five = not False
# 11 조건문(Conditional Statement)의 문법
response = "Y"
answer = "Left"
if answer == "Left":
print ("This is the Verbal Abuse Room, you heap of parrot droppings!")
This is the Verbal Abuse Room, you heap of parrot droppings!
# 12 만약(if) 여러분이...
def using_control_once():
if 1 == 1:
return ("Success #1")
def using_control_again():
if not False:
return ("Success #2")
print (using_control_once())
print (using_control_again())
Success #1 Success #2
# 13 그 외에(else) 문제가 있다면, 유감입니다…
answer = "'Tis but a scratch!"
def black_knight():
if answer == "'Tis but a scratch!":
return True
else:
return False # Make sure this returns False
def french_soldier():
if answer == "Go away, or I shall taunt you a second time!":
return True
else:
return False # Make sure this returns False
print( black_knight() )
print( french_soldier() )
True False
# 14 수많은 문제가 있지만, Switch는 문제가 아니죠.
def greater_less_equal_5(answer):
if answer > 5:
return 1
elif answer < 5:
return -1
else:
return 0
print (greater_less_equal_5(4))
print (greater_less_equal_5(5))
print (greater_less_equal_5(6))
-1 0 1
# 15 The Big If
def the_flying_circus():
if 1 == 2 and 3 != 4 or not 5 < 6 and 7 <= 8 or 9 > 10 and 11 >= 10:
print ("if evaluated")
return True
elif True:
print ("elif evaluated")
return True
else:
print ("Impossible to reach here")
return False
the_flying_circus()
elif evaluated
True