Monday, 10 August 2026

stack practice

 A stack, named ClrStack, contains records of some colors. Each

record is represented as a tuple containing four elements -

ColorName, RED, GREEN, BLUE. For example, ('Yellow', 237, 250, 68).

Write the following user-defined functions in Python to

perform the specified operations on ClrStack:

(i) push_Clr(ClrStack, new_Clr): This function takes the stack

ClrStack and a new record new_Clr as arguments and pushes this new

record onto the stack.

(ii) pop_Clr(ClrStack): This function pops the topmost record from the

stack and returns it. If the stack is already empty, the function

should display the message "Underflow".

(iii) isEmpty(ClrStack): This function checks whether the stack is

empty. If the stack is empty, the function should return True,

otherwise the function should return False

(iv) display(ClrStack): This function to display all the elements of

the stack by popping it. In the end it should display "Stack Empty"