Multiple choice › Python syntax
Python syntax
1. Python syntax
Which Python code correctly prints the larger of two numbers a and b?
option set A-D shown below
- if a > b: print(a) else: print(b)
- if a > b print(a) else print(b)
- if (a > b) { print(a) } else { print(b) }
- IF a > b THEN print(a) ELSE print(b)
Answer
A
Python uses a colon after if/else and indentation for blocks. The other options are pseudocode or other languages.