Computer Science, asked by ronychakraborty7500, 1 month ago

>>>word="amazing" >>>word[:3]+word[3:] Give the output

Answers

Answered by anindyaadhikari13
4

\texttt{\textsf{\large{\underline{Given C{o}de}:}}}

word='amazing'

print(word[:3]+word[3:])

\texttt{\textsf{\large{\underline{O{u}tput}:}}}

The output of the co‎de is:

amazing

\texttt{\textsf{\large{\underline{Calculations}:}}}

Let us write the index of the characters present in the string.

 \boxed{\begin{array}{c|c}\sf\underline{Character}:&\sf\underline{Index}:\\ \sf a&\sf0\\ \sf m&\sf1\\ \sf a&\sf2\\ \sf z&\sf3\\ \sf i&\sf 4\\ \sf n&\sf 5\\ \sf g&\sf 6\end{array}}

> word[ : 3] returns the substring from index 0 to 2.

> word[ : 3] = 'ama'

> word [3 : ] returns the substring from index 3 to end (i.e., 6)

> word[3 : ] = 'zing'

Concatenating both string,

> new word = 'amazing'.

So, the output for the given co‎de is - amazing

Similar questions