ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import string
print(string.ascii_lowercase.index('z') - string.ascii_uppercase.index('A'), len(string.digits + string.punctuation))
  1. A. 25 43
  2. B. 25 42
  3. C. 26 42
  4. D. 25 36

Correct answer: B. 25 42

'z' has index 25 in ascii_lowercase and 'A' has index 0 in ascii_uppercase, giving 25. There are 10 digits and 32 punctuation characters, so the total is 42.

More Python Programming questions

Exams that ask this topic