PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 92


Assuming that the snippet below has been executed successfully, which of the following expressions evaluate to True? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2]

Show Answer
Correct Answer: AD

First, we evaluate 'python'[::2], which returns 'pto' by selecting every second character from the string. Then, we set string to string[-1] + string[-2], which takes the last character 'o' and the second-last character 't', resulting in 'ot'. We assess the options as follows: string[0] == 'o' is true because 'o' is the first character of 'ot'. len(string) == 3 is false because the length of 'ot' is 2. string is None is false because the string variable contains 'ot'. string[0] == string[-1] is false because the first character 'o' and the last character 't' of 'ot' are not the same.

Discussion

12 comments
Sign in to comment
macxsz
Apr 28, 2022

A is the only True

petibi
May 3, 2022

hello, is your PCAP exam done?

andr3
Mar 19, 2023

is yours ?

Veilok
Aug 21, 2023

is yours?

petibi
May 3, 2022

Yes only A is True

cvvvv
May 19, 2022

A is the correct answer.

Damon54
Feb 7, 2024

Maybe that's the case, I ask whoever took the exam to explain Assuming that the snippet below has been executed successfully, which of the following expressions evaluate to False? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2] string = 'python'[::2] string = string[-1] + string[-2] print (string[0] == 'o') print (string is None ) print (len(string) == 3) print (string[0] == string [-2]) True False False True

moteruky
Feb 18, 2024

String [-1] + string[-2] gives ot Print(string [0]==o TRUE String[0]==String [-2]

carpmatiasOptions: AD
May 11, 2022

Shouild be A: >>> string = 'python'[::2] >>> string 'pto'

stuartzOption: A
Jun 15, 2022

only A because >>> 'python'[::2] 'pto' >>> string = 'python'[::2] >>> string 'pto' >>> string = string[-1] + string[-2] >>> string 'ot' >>> string[0] 'o' >>> string[-1] 't'

Jnanada
Aug 19, 2022

only A is true

MallieOption: A
Jan 2, 2023

Only A is correct

andr3Option: A
Mar 25, 2023

once snippet executes we are left with "'ot" only

clecorre
Aug 23, 2023

Hello everybody, my PCAP is set for next Monday. I see many errors in these exercises, and I'm very worried. Is the (real) exam full of errors like this ?

brandonkim76
Sep 5, 2023

how did it go?

seaverickOptions: AD
Jan 21, 2024

#question 2 string = 'python'[::2] string = string[-1] + string[-2] print(string) print(string[0]) print(len(string)==3)#False print(string is None)#False print(string[0]==string[-1])#False print(string[0]=='o')#True Tested: A (string[0]=='o)

Damon54Options: AC
Feb 13, 2024

A. string[0] == 'o' C. len(string) == 3

Damon54
Feb 14, 2024

No correct