Friday , September 20 2024

The following code: print(ord(‘c’) – ord(‘a’)) prints:

Questions BankCategory: Python Essentials 2The following code: print(ord(‘c’) – ord(‘a’)) prints:
The following code:

print(ord('c') - ord('a'))
 

prints:
  • 0
  • 3
  • 1
  • 2

Explanation: The ord() function in Python returns the Unicode code of the given character. A lower-case c returns 99, and a lower-case a returns 97. Therefore, 99 minus 97 equals 2. This is what is printed in the console.

More Questions: Python Essentials 2 – Module 2 Test