Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a question regarding python and passing data. I understand that myStack.push(somevalue) will push itself and somevalue. That is, it's passes 2 arguments. foo

I have a question regarding python and passing data.

I understand that myStack.push(somevalue) will push itself and somevalue. That is, it's passes 2 arguments.

foo = function that returns a tuple with 3 values (somevalue1, somevalue 2, somevalue3)

I tried myStack.push([foo]) because I wanted to start a list with the return values from foo, but the interpreter said that is only 1 argument.

I then tried mystack.push(foo, [ ]) but then it said that is 3 arguments

I want to know what is going on with this call: myStack.push((foo , [ ] )) and why that works as 2 arguments. Am I really pushing the values onto myStack as a list or is it doing something I am not understanding?

image text in transcribed

class Stack: "A container with a last-in-first-out (LIFO) queuing policy." def _init__(self): self.list = [] | def push(self, item): "Push 'item' onto the stack" self.list.append(item) def pop (self): "Pop the most recently pushed item from the stack" return self.list.pop() def isEmpty (self): "Returns true if the stack is empty" return len(self.list) == 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Discuss the importance of linking pay to ethical behavior.

Answered: 1 week ago

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago