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]
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]
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.
A is the only True
hello, is your PCAP exam done?
is yours ?
is yours?
Yes only A is True
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
String [-1] + string[-2] gives ot Print(string [0]==o TRUE String[0]==String [-2]
A is the correct answer.
Shouild be A: >>> string = 'python'[::2] >>> string 'pto'
A. string[0] == 'o' C. len(string) == 3
No correct
#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)
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 ?
how did it go?
once snippet executes we are left with "'ot" only
Only A is correct
only A is true
only A because >>> 'python'[::2] 'pto' >>> string = 'python'[::2] >>> string 'pto' >>> string = string[-1] + string[-2] >>> string 'ot' >>> string[0] 'o' >>> string[-1] 't'