Home

Designed for school students & undergraduate entrance aspirants preparing for board exams, NEET, JEE and more.

JEE (Mains & Adv)NEET (UG)CBSE BoardISC BoardUP BoardCUET

Built for graduates & professionals targeting competitive exams — UPSC, CAT, GMAT, GRE, IELTS, banking & more.

GREGMATCATUPSCIBPSIELTSTOEFLSATACT

Core school & undergraduate subjects aligned with CBSE, ISC, UP Board, NEET and JEE syllabi.

PracticeMock TestsResources

Computer Science > Computational Thinking And Programming 2 > Data Structures

Success Rate: 0%
Single Question

Write the following user-defined functions in Python :

(i)

push_trail(N, myStack)
: Here
N
and
myStack
are lists, and
myStack
represents a stack. The function should push the last 5 elements from the list
N
onto the stack
myStack
. For example, if the list
N
is
[1, 2, 3, 4, 5, 6, 7]
, then the function
push_trail()
should push the elements
3, 4, 5, 6, 7
onto the stack. Therefore the value of stack will be
[3, 4, 5, 6, 7]
. Assume that
N
contains at least 5 elements.

(ii)

pop_one(myStack)
: The function should pop an element from the stack
myStack
, and return this element. If the stack is empty, then the function should display the message
'Stack Underflow'
, and return
None
.

(iii)

display_all(myStack)
: The function should display all the elements of the stack
myStack
, without deleting them. If the stack is empty, the function should display the message
'Empty Stack'
.

Edvaya Target App Icon

Edvaya Target

Board & Competitive Exams Made Easy

Edvaya Target is built for students preparing for JEE (Main & Advanced), NEET UG, and Board Exams (CBSE, ISC & State Boards) — using a practice-first approach that actually works.

Get it on Google Play

Current Question

Attempts0/3
StatusNot Answered
Ready to Answer! 🚀

Community Stats

Active Learners30
Questions Attempted560
Community Success Rate71%

Track Your Progress

Sign up to save your practice progress, add favorites, and get personalized insights.

Quick Actions

We Value Your Privacy

Edvaya uses cookies to enhance your learning experience, analyze platform usage, and provide personalized content. You can customize your preferences or accept all cookies to continue.

By continuing, you agree to our Cookie Policy and Privacy Policy