Computer Science, asked by aarusharma094, 5 months ago

What will be the output of the following python print statements for the string? str = 'SUNDEW' i) print(str*2) ii) print(str[4:]).​

Answers

Answered by AdarshChahar
1

Answer:

What will be the output of the following python print statements for the string? str = 'SUNDEW' i) print(str*2) ii) print(str[4:]).

ueh54

Answered by purveshKolhe
2

\bf{\underline{Anwser::}}

i) SUNDEWSUNDEW

ii) EW

\rule{300pt}{0.2em}

\bf{\underline{Logic::}}

  • The first statement outputs the string twice. It is because when we use multiplication operator after a string, it gets printed the number of times it is multiplied with.
  • The statement str[4:] returns all the characters from fourth index[fifth character] to the last character.

\rule{300pt}{0.2em}

\bf{\underline{Lists\:in\:python::}}

  • In Python, a list is a collection of items or elements, which can be of any data type (e.g. integers, strings, or other lists).
  • Lists are mutable, meaning you can add, remove, or modify elements in a list after it has been created.
  • You can create a list by enclosing comma-separated elements in square brackets.
  • You can access elements in a list using their index, which starts at 0 for the first element.
  • You can modify elements in a list by assigning a new value to the element at a specific index.

\rule{300pt}{0.2em}

Similar questions