Embercode
✕
Variables and Data TypesQuick quiz

Char arithmetic and ranges

8 questions. Covers Integer ranges and two's complement in Python.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``python print('a' + 'b' + ' ' + chr(ord('a') + 2)) ``
  2. 2. What does this program print? ``python ch = 'x' ch = chr(ord(ch) + 2) print(ch, ord(ch)) ``
  3. 3. Spot the bug. What happens when this runs? ``python c = 'a' c = c + 1 ``
  4. 4. Which expression turns a lowercase letter ch into an index from 0 to 25?
  5. 5. What number does ord('7') - ord('0') produce?

    Type your answer.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.