Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

kindly consider the stack machine rules given and write the code in PYTHON accor

ID: 3717827 • Letter: K

Question

kindly consider the stack machine rules given and write the code in PYTHON according to it..

Create a Stack Machine (in any language you wish, I would use Python) to validate the language XXR, that is, the language of palindromes. The input to the program can either be a user entry (via command line or GUI) or from a text file. The output will be a series of lines indicating the current input symbol to be read, the current top of the stack and the stack after elements have been placed onto the stack: The output should look something like this: Move Top of Input Stack after move Stack Start abbbba Move 1 [albbbba Sa

Explanation / Answer

PYTHON CODE:

stack.py

class Stack:

def __init__(self):

self.items =[ ]

def isEmpty(self):

return == [ ]

def push (self, item):

self.items. append(item)

def pop(self):

return items.pop( )

def peek(self):

return items.[len(self.items)-1]

def size(self):

return len(self.items)

from stackDS import Stack

def isPalindrome(word):

if len(word) < 2: return True

if word [0] ! = word [-1]: return False

return isPalindrome(word[1:-1])

return True

Test isPalindrome

print (isPalindrome("maam")) #Expected Output : TRUE

print (isPalindrome("madam")) #Expected Output : TRUE

print (isPalindrome("hello")) #Expected Output : FALSE

print (isPalindorme("Macdam")) #Expected Output : FALSE

print (isPalindrome("buffalolaffub")) #Expected Output : TRUE

print (isPalindrome("argentina")) #Expected Output : FALSE