Home › Olympiad (Class 10) › Computer Science › Booleans and Decisions › Instead of writing if is_raining == True, a tidy…
Instead of writing if is_raining == True, a tidy programmer writes:
Aif is_raining()
Bif is_raining[]
Cif is_raining{}
Dif is_raining
Answer & Solution
Correct answer: D. if is_raining
1. The variable already holds True or False.
2. Comparing it to True adds nothing.
3. So write if is_raining.
_Source: OpenStax Introduction to Python Programming, Chapter 4._
Related questions
An elif statement is only legal when it directly follows an if or another:A curve program uses two separate if statements and both run by mistake. The fix is to useMost Python operators are evaluated in which direction?The rule deciding order when two operators share a precedence level is:In Python the expression (1 + 2) * 3 evaluates to:In Python the expression 1 + 2 * 3 evaluates to:A program should act when a computer is switched off. The operator to use is:A concert lets in anyone in band or choir. The operator to use is: