Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Codecademy Python Course Help

    "Conditionals & Control Flow"

    Quote Originally Posted by Codecademy
    Write an if statement in the_flying_circus(). It must include:

    if, elif, and else statements;
    At least one of and, or, or not;
    A comparator (==, !=, <, <=, >, or >=);
    Finally, the_flying_circus() must return True when evaluated.

    Don't forget to include a : after your if statements!

    Hint:

    Be careful with your indentation—the_flying_circus() is a function (which we'll get to in the next unit), and as you can see from the comment, function blocks are indented the same way if, elif, and else blocks are.

    Your code should look something like this:
    I'm having a tough time on this one.

    What they start you out with:

    # Make sure that the_flying_circus() returns True
    def the_flying_circus():
    if ________: # Start coding here!
    # Don't forget to indent
    # the code inside this block!
    elif ________:
    # Keep going here.
    # You'll want to add the else statement, too!
    What I've got so far:

    # Make sure that the_flying_circus() returns True
    def the_flying_circus():
    if () > 10:
    print "More than 10!"
    # Start coding here!
    # Don't forget to indent
    # the code inside this block!
    elif () < 10:
    print "Less than 10!"
    # Keep going here.
    # You'll want to add the else statement, too!
    else:
    print "10!"
    print the_flying_circus

    I just can't get my head around what's wanted and what I'm not doing right.

    Can anyone help me out?

  2. #2
    New Coder
    Join Date
    Nov 2016
    Location
    South Africa, Cape Town
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    I'm not sure what they want you to do but from what I can see it's a simple function to check if the parameter parsed is less than or greater than 10.

    Use this as a guideline:

    Code:
    def myFunction(num):
        if num > 10:
            print "Greater than 10"
        elif num < 10:
            print "Less than 10"
        else:
            print str(num) + " is not greater than or less than 10"
    
    myFunction(5)


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •