English

A list containing records of products as  L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)] Write the following user-defined function to perform an operation - Computer Science (Python)

Advertisements
Advertisements

Question

A list containing records of products as 

L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)]

Write the following user-defined function to perform an operation on a stack named Product to:

Push_element() – To push an item containing the product name and price of products costing more than 50 into the stack.

Output:

('Laptop', 90000), 
('Mobile', 30000),
('Headphones', 1500)
Code Writing
Advertisements

Solution

L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)]
product = []
def Push_element(L):
   for i in L:
      if i[1] > 50:
         product.append(i)
   print(product)
shaalaa.com
  Is there an error in this question or solution?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×