Assuming that the snippet below has been executed successfully, which of the following expressions will 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 will evaluate to True? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2]
After executing the provided code snippet, 'python'[::2] results in 'pto'. Assigning string the value of its last two characters reversed ('ot'), we can evaluate the options. As 'len(string)' evaluates to 2, option A ('len(string) == 3') is false. 'string[0]' is 'o', so option B ('string[0] == 'o'') is true. 'string[0]' being equal to 'string[-1]' (both 'o') makes option C true. Finally, option D ('string is None') is false since string clearly holds the value 'ot'. Therefore, the correct answers are B and C.
Sorry only B: string = 'python'[::2] string = string[-1] + string[-2] print(len(string) == 3 ) print(string[0] == 'o' ) print( string[0] == string[-1] ) print( string is None)
A, B is correct string = 'python'[::2] print(string) pto R: print(len(string) == 3 ) string = string[-1] + string[-2] print(string) ot print(string[0] == 'o' )
B is the correct
Only C is True string = 'python'[::2] string = string[-1] + string[-2] print(len(string) == 3 ) print(string[0] == 'o' ) print( string[0] == string[-1] ) print( string is None)