Exam PCAP All QuestionsBrowse all questions from this 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]

    Correct Answer: A, D

    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
macxsz

A is the only True

petibi

hello, is your PCAP exam done?

andr3

is yours ?

Veilok

is yours?

petibi

Yes only A is True

Damon54

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

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

cvvvv

A is the correct answer.

carpmatiasOptions: AD

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

Damon54Options: AC

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

Damon54

No correct

seaverickOptions: AD

#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)

clecorre

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

how did it go?

andr3Option: A

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

MallieOption: A

Only A is correct

Jnanada

only A is true

stuartzOption: A

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