TK Study

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

  1. if a > b: print(a) else: print(b)
  2. if a > b print(a) else print(b)
  3. if (a > b) { print(a) } else { print(b) }
  4. 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.