Codecademy Python Answers Conditionals And Control Flow

 Also Read: How To Chat With Your Friend Using Command Prompt

Conditionals and Control Flow 1/15 – Go With Flow

def clinic():
    print "You've just entered the clinic!"
    print "Do you take the door on the left or the right?"
    answer = raw_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()

Conditionals and Control Flow 2/15 – Compare Closely!

# Assign True or False as appropriate on the lines below!

# Set this to True if 17 < 328 or to False if it is not.
bool_one = True   # We did this one for you!

# Set this to True if 100 == (2 * 50) or to False otherwise.
bool_two = True

# Set this to True if 19 <= 19 or to False if it is not.
bool_three = True

# Set this to True if -22 >= -18 or to False if it is not.
bool_four = False

# Set this to True if 99 != (98 + 1) or to False otherwise.
bool_five = False

Conditionals and Control Flow 3/15 – Compare Closier

# Assign True or False as appropriate on the lines below!

# (20 - 10) > 15
bool_one = False    # We did this one for you!

# (10 + 17) == 3**16
# Remember that ** can be read as 'to the power of'. 3**16 is about 43 million.
bool_two = False

# 1**2 <= -1
bool_three = False

# 40 * 4 >= -4
bool_four = True

# 100 != 10**2
bool_five = False

Conditionals and Control Flow 4/15 – How the tables have turned

# Create comparative statements as appropriate on the lines below!

# Make me true!
bool_one = 3 < 5  # We already did this one for you!

# Make me false!
bool_two = 5<1

# Make me true!
bool_three = 1<5

# Make me false!
bool_four = 1>5

# Make me true!
bool_five = 1+4==5

Conditionals and Control Flow 5/15 – To be and/or not to be

"""
     Boolean Operators
------------------------      True and True is True
True and False is False
False and True is False
False and False is False

True or True is True
True or False is True
False or True is True
False or False is False

Not True is False
Not False is True

"""

Conditionals and Control Flow 6/15 – And

bool_one = False 

bool_two = False

bool_three = False

bool_four = True

bool_five = True

Conditionals and Control Flow 7/15 – OR

bool_one = True

bool_two = True

bool_three = False

bool_four = True

bool_five = False

Conditionals and Control Flow 8/15 – NOT

bool_one = False

bool_two = True 

bool_three = True

bool_four = True

bool_five = False

Conditionals and Control Flow 9/15 – This and That

bool_one = False

bool_two = True

bool_three = True

bool_four = True

bool_five = False

Conditionals and Control Flow 10/15 – Mix ‘n’ Match

# Use boolean expressions as appropriate on the lines below!

# Make me false!
bool_one = (2 <= 2) and "Alpha" == "Bravo"  # We did this one for you!

# Make me true!
bool_two = 5==5

# Make me false!
bool_three = 5!=5

# Make me true!
bool_four = 6==6

# Make me true!
bool_five = 7==7

Conditionals and Control Flow 11/15 – Conditional Statement Syntax

response = 'Y'

answer = "Left"
if answer == "Left":
    print "This is the Verbal Abuse Room, you heap of parrot droppings!"
    
# Will the above print statement print to the console?
# Set response to 'Y' if you think so, and 'N' if you think not.

Conditionals and Control Flow 12/15 – If you’re Having

def using_control_once():
    if 5==5:
        return "Success #1"

def using_control_again():
    if 10==10:
        return "Success #2"

print using_control_once()
print using_control_again()

Conditionals and Control Flow 13/15 – Else problems,I feel bad for you,son

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

Conditionals and Control Flow 14/15 – I got 99 problems But Ain’t 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)

Conditionals and Control Flow 15/15 – The Big IF

# Make sure that the_flying_circus() returns True
def the_flying_circus():
    if (5==5) and (6==6):    # Start coding here!
        return True
    elif 5>5:
        return False
    else:
        return True
Latest Comments
  1. nana March 10, 2017
    • prathap March 10, 2017
    • vincento July 6, 2017
  2. Marko May 10, 2017
    • prathap May 10, 2017

Leave a Reply

Your email address will not be published. Required fields are marked *