I need some help with a basic script 01-05-2015, 05:15 PM
#1
Hey guys,
Learning some Python here and I'm a little bit stuck on a script I need to write. Basically the instructions are as follows:
The Big If
Really great work! Here's what you've learned in this unit:
Comparators
Boolean operators
Conditional statements
Let's get to the grand finale.
Instructions
Write an if statement in the_flying_circus(). It must include:
Don't forget to include a ":" after your if statements!
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 just keep getting stuck because I don't think I fully understand the actual idea behind some of these concepts. Specifically booleans. If someone could help me out with this code and then actually explain like I'm five how you did I would really appreciate it!
Thanks in advanced haha!
Learning some Python here and I'm a little bit stuck on a script I need to write. Basically the instructions are as follows:
The Big If
Really great work! Here's what you've learned in this unit:
Comparators
Code:
3 < 4
5 >= 5
10 == 10
12 != 13Boolean operators
Code:
True or False
(3 < 4) and (5 >= 5)
this() and not that()Conditional statements
Code:
if this_might_be_true():
print "This really is true."
elif that_might_be_true():
print "That is true."
else:
print "None of the above."Let's get to the grand finale.
Instructions
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!
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:
Code:
def the_flying_circus():
if condition:
# Do something!
elif condition:
# Do something else!
else:
# Do yet another thing!I just keep getting stuck because I don't think I fully understand the actual idea behind some of these concepts. Specifically booleans. If someone could help me out with this code and then actually explain like I'm five how you did I would really appreciate it!
Thanks in advanced haha!
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)























![[Image: tenor.gif]](https://media.tenor.com/images/40e171e6954998e4c640c1a106cd238c/tenor.gif)