Q. Using the string truehuman = 'Loves One and All', what would be returned by following string slices?
| Expression | Output string | |
|---|---|---|
| (a) | truehuman [- 7 : - 3] | |
| (b) | truehuman [ - 3 :] | |
| (c) | truehuman [- 9 : - 3] | |
| (d) | truehuman [: 10] | |
| (e) | truehuman [12 :] | |
| (f) | truehuman [10 : -12] | |
| (g) | truehuman [9:] + truehuman [:9] | |
| (h) | truehuman [: 9] + truehuman [9 : ] |
Answer :-
| Expression | Output string | |
|---|---|---|
| (a) | truehuman [- 7 : - 3] | 'and ' |
| (b) | truehuman [ - 3 :] | 'All' |
| (c) | truehuman [-9 : -3] | 'e and ' |
| (d) | truehuman [: 10] | 'Loves One ' |
| (e) | truehuman [12 :] | 'd All' |
| (f) | truehuman [10 : - 12] | '' |
| (g) | truehuman [9:] + truehuman [:9] | ' and AllLoves One' |
| (h) | truehuman [: 9] + truehuman [9 : ] | 'Loves One and All' |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )