exam questions

Exam PCAP-31-03 All Questions

View all questions & answers for the PCAP-31-03 exam

Exam PCAP-31-03 topic 1 question 75 discussion

Actual exam question from Python Institute's PCAP-31-03
Question #: 75
Topic #: 1
[All PCAP-31-03 Questions]

Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Choose two.)

string = 'REPTILE'[:3:]
string = string[-1] + string[-2::-1]

  • A. len(string) == 3
  • B. string[0] == 'E'
  • C. string[0] < string[-1]
  • D. string is None
Show Suggested Answer Hide Answer
Suggested Answer: AC 🗳️

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
flthymcnsty
4 months, 3 weeks ago
Selected Answer: AC
Explanation Step-by-Step Breakdown string = 'REPTILE'[:3:] The slicing [:3:] takes the first 3 characters of the string ‘REPTILE'. Result: string = 'REP'. string = string[-1] + string[-2::-1] string[-1]: Takes the last character of 'REP', which is ‘P'. string[-2::-1]: Reverses the string up to the second-to-last character: string[-2] is 'E', and string[-2::-1] reverses 'RE' to ‘ER'. Concatenate: 'P' + 'ER' -> string = ‘PER’. The correct answers are: A. len(string) == 3 The length of 'PER' is 3. This evaluates to True. C. string[0] < string[-1] string[0] is 'P' and string[-1] is ‘R'. 'P' < 'R' is True because 'P' comes before 'R' in ASCII order. The incorrect answers are: B. string[0] == 'E' string[0] is 'P', not 'E'. D. string is None string is 'PER', so it is not None.
upvoted 3 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago