Datastructre Class Test
Datastructre Class Test
2. Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of stationary items–
{Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also display the count of
elements pushed into the stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be:
The count of elements in the stack is 2
Code - 2
def pop(Country):
if ______________: #Statement 3
return "Under flow"
else:
return Country.________() #Statement 4
#Function Calling
for i in range(len(Country)+1):
print(_______________) #Statement 5
Required Output:
Sri Lanka
UK
India
Under flow
Fill the above statement based on given questions:
i. Identify the suitable code for the blank of statement 1.
a. .append()
b. .insert()
c. .extend()
d. .append(len(Country),N)
ii. Fill the statement 2, to insert the alternate element from Country
list.
a. 3
b. 0
c. -1
d. 2
iii. Fill the statement 3, to check the stack is empty.
a. Country=[]
b. Country.isEmpty()
c. len(country)==0
d. No of the above
iv. Fill the statement 4, to delete an element from the stack.
a. pop(1)
b. pop()
c. del country[1]
d. Country.delete(1)