if, else, and elif Statements
Read this for more on conditional statements.
5. Multiple if statements
For the code snippets below, make sure to note that multiple if statements can execute when a given condition is satisfied.
Consider the following code fragment:
if num >= 10: print("A") if num >= 0: print("B") if num < 0: print("C") if num < -10: print("D")What would the program output if num = 12?
Consider the following code fragment:
if num >= 10: print("A") if num >= 0: print("B") if num < 0: print("C") if num < -10: print("D")What would the program output if num = 1?
Consider the following code fragment:
if num >= 10: print("A") if num >= 0: print("B") if num < 0: print("C") if num < -10: print("D")What would the program output if num = -1?
Consider the following code fragment:
if num >= 10: print("A") if num >= 0: print("B") if num < 0: print("C") if num < -10: print("D")What would the program output if num = -12?