Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
Location Chicago IL, USA

Exam PCAP topic 1 question 15 discussion

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

Assuming that String is six or more letters long, the following slice string [1:-2] is shorter than the original string by:

  • A. four chars
  • B. three chars
  • C. one char
  • D. two chars
Show Suggested Answer Hide Answer

Suggested Answer: A

Comments

locloc91
6 months, 2 weeks ago
Let's assume that String has exactly 6 chars. Then String[1: -2] has 3 characters. So the difference is three, isn't it?
upvoted 4 times
...
faltu1985
5 months, 1 week ago
It should be 3 a = [0,1,2,3,4,5,6,7] a[1:-2] gives output as 5 characters which are 3 short of total 8 - a
upvoted 2 times
...
SophieSu
3 months ago
a="123456" b=a[1:-2] ="234" print(len(a)-len(b)) =3
upvoted 2 times
...
anjuvinayan
2 months, 3 weeks ago
Answer is 3 as stated by others
upvoted 2 times
...
cynthia_mervy
2 weeks, 5 days ago
the answer is 3 because it does not include the value of -2
upvoted 1 times
...

SaveCancel