Computer Science, asked by kashishkhajuria4, 8 months ago

What is the value of second after executing the following lines?
first = "tarantula"
second = ""
for i in range(len(first)-1,-1,-1):
second = first[i] + second

Answers

Answered by kumkumsharma297
4

Answer:

Explanation:vyxtvrzugthgsidthrhgzidthtgufudyjtgudycthrhyduduf

Answered by AskewTronics
0

It will prints "tarantula" which is the value of the second variable.

Explanation:

  • The first variable holds one string which is reversely scanned by the for loop and assigned to the variable second.
  • The value assigned on the second variable is fixed with the previous letter of the second variable value.
  • For example, if the "second" variable holds the value 'i' and 'e' will be assigned on it then the value will be made after the assignment is "ei".
  • It is because the expression above is "first[i]+second" if the expression is second+first[i], then the second variable holds the reverse of the first variable value.
  • The for loop scan the character from last to first because the initial value in the for loop is given as "len-1", the operation is decrement and the last value is -1 for i index.

Learn More:

  • Python :https://brainly.in/question/14689905
Similar questions