Home
Activities
Resources
CONTACT US
🔊
What is printed in the program?
derek_is_happy =
True
if derek_is_happy:
print(
"True"
)
else:
print(
"False"
)
🔊
Notice that only the print("True") is part of the If-statement. The print("False") is part of the else.
True False
True
False
Nothing will be printed.
🔊
Choose an answer above!
Back
Help me
🔊
Now that we know about conditional and logical operators, let's see how they can be used in If-statements.
🔊
As we have seen, if statements allow you to control the flow of execution based on a condition.
🔊
A condition can only ever be True or False.
🔊
This means Booleans, conditional operators, and logical operators can be used to create a condition for an If-statement.
🔊
When the condition is True, everything that is under the if statement and indented will be executed.
🔊
On this page, the indents will be highlighted yellow so you can easily see what is part of the If-statement.
🔊
Also, remember the 'else' will be executed if the If-statement fails.
🔊
The 'else' isn't required but is helpful when you want to execute code when the If-statement fails.
Next
Help for Variables
Close modal
The correct answer(s) is:
Option 2. Make sure to read the explanation!
Close help