LearnFrenzy
Sign in Take a free test

Strings · Predict the Output · Question 11

ord() and chr() Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What is the output of the following Python program?

main.py
print(ord("A"), chr(97), chr(ord("a") + 25), ord("0"), chr(ord("7") - 2))
  • A 65 a z 48 5 Correct
  • B 65 a z 0 5
  • C 97 A z 48 5
  • D 65 a y 48 5
Correct Answer: Option A

"A" is 65, "a" is 97, so 97 + 25 = 122 is "z". The digit characters start at 48; ord("7") - 2 is the code of "5".

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links