-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
One of the most common blunders a novice can make is to use if-elif-else blocks instead of using a single return statement.
For instance
if a:
return True
elif b:
return True
else:
return Falseshould simply be written
return a or bThe introduction sets up using if:elif:else: blocks. I fear that a novice will blindly fall into the trap of solving task 1 using an if.
def is_criticality_balanced(temperature, neutrons_emitted):
if temperature < 800 and neutrons_emitted > 500 and temperature * neutrons_emitted < 500_000:
return True
else:
return Falseor something even worse, when it should be solved with a single return statement.
def is_criticality_balanced(temperature, neutrons_emitted):
return temperature < 800 and neutrons_emitted > 500 and temperature * neutrons_emitted < 500_000buster-blue