Question

using python to Design and implement an application that reads a word from the user and...

  • using python to Design and implement an application that reads a word from the user and prints the characters of each word backwards.
    • Use a stack to reverse the characters of each word.
  • What is the difference between a queue and a stack?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the answer below::

while True:
word = input("Enter a word or quit to exit : ")
if word=="quit":
break
stack = []
for c in word:
stack.append(c)
print("Reverse is : ",end="")
while len(stack)>0:
c = stack.pop()
print(c,end="")
print()

Stack Represents the collection of elements in Last In First Out order, So if we are inserting something into Stack , it will come out first , Just like storing something in the box, Whatever we are putting into the box at the end, It will come first while picking .

While Queue represent data flow in First in First Out manner, So whatever inserted first will come first out, Just like ticket count , Who comes first will get ticket first and leave the queue.

Add a comment
Know the answer?
Add Answer to:
using python to Design and implement an application that reads a word from the user and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT