Computer Science, asked by radhika28agrawal, 5 months ago

What will this program display? Help urgently! Python experts.

word = "keyboard"
result = ''
for sign in word:
result = sign + result
print(result)​

Answers

Answered by MichMich0945
1

Pretty small answer but hope this helps you ♥

Attachments:
Answered by dreamrob
0

Code :

word = "keyboard"

result = ''

for sign in word:

    result = sign + result

print(result)​

Output :

draobyek

Explanation :

The above code is for reversing the given string.

This statement : for sign in word:  Loop through the letters in the word

This statement : result = sign + result  is used for concatenation of the strings.

  1. result = k + " = k
  2. result = e + k = ek
  3. result = y + ek = yek
  4. result = b + yek = byek
  5. result = o + byek = obyek
  6. result = a + obyek = aobyek
  7. result = r + aobyek = raobyek
  8. result = d + raobyek = draobyek

So, final output is draobyek.

Attachments:
Similar questions