Q. Given a string S = "CARPE DIEM", If n is length/2 (length is the length of the given string),then what would following return?
(a)S[:n]
(b)S[n:]
(c)S[n:n]
(d)S[1:n]
(e)S[n:length:-1]
You can understand by Watching video :-
Answer :-
n = length/2
n = 5
(a) ‘CARPE’
(b) ‘ DIEM’
(c) ‘’
(d) ‘ARPE’
(e) Error
a option is wrong
ReplyDelete(a)'CARPE'
no time to check other options bye
Ok, I have fixed it.
Deletes= "CARPE DIEM"
ReplyDeleten =int(len(s)/2)
print (s[:n])
CARPE
What happened ??
Deletewhy the last one is error
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )