Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 53 discussion

Actual exam question from Python Institute's PCAP
Question #: 53
Topic #: 1
[All PCAP Questions]

Which of the equations are True? (Choose two.)

  • A. chr (ord (x)) = = x
  • B. ord (ord (x)) = = x
  • C. chr (chr (x)) = = x
  • D. ord (chr (x)) = = x
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
lukaki
Highly Voted 3 years ago
A,D: x = 'x' print(chr(ord(x)) == x) #True print(ord(ord(x)) == x) # it will generate TypeError print(chr(chr(x)) == x) # it will generate TypeError print(ord(chr(x)) == x) # it will generate TypeError #Example2 x = 1 print(chr(ord(x)) == x) # it will generate TypeError print(ord(ord(x)) == x) # it will generate TypeError print(chr(chr(x)) == x) # it will generate TypeError print(ord(chr(x)) == x) #True
upvoted 12 times
baimus
1 year, 7 months ago
A D is what they intend, but the question should then read "which of these options could EVER be True, but never simulataneously" (which isn't a great question)
upvoted 1 times
...
...
TheFivePips
Most Recent 11 months, 3 weeks ago
I hate this question becuase the answer depends on what the variable x is. ord() expects a character and returns an int. chr() expects and int and returns a character.
upvoted 1 times
...
palagus
2 years, 6 months ago
I concur with lukaki. It depends on the value of x.
upvoted 1 times
...
macxsz
2 years, 7 months ago
Selected Answer: A
only correct answer: A. chr (ord (x)) = = x
upvoted 4 times
...
rbishun
3 years ago
So the question is written incorrectly...
upvoted 1 times
...
rbishun
3 years ago
""" Notes: ord(str|byte) -> int chr(int) -> str """ x = 5 print(chr(ord('x')) == 'x') # True print(ord(chr(x)) == x) # True
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...