Question: please write code in python. Thank you! In Python, a tuple is a collection similar to a list in that it is an ordered collection

please write code in python. Thank you! In Python, a tuple isa collection similar to a list in that it is an orderedcollection of items. An important difference, however, is that a tuple isplease write code in python. Thank you!

In Python, a tuple is a collection similar to a list in that it is an ordered collection of items. An important difference, however, is that a tuple is immutable - once created, a tuple cannot be changed. Also, tuples are denoted using parentheses instead of square brackets. As with lists, elements of a tuple are accessed using indexing notation. For example, given the tuple subjects = (, physics, , , chemistry, , , biology, ) , we could ac- cess the elements of the tuple using subjects [0], subjects[1] and subjects [2]. Write a function checkout (), which takes a single argument, candies, which is a list of tuples, Each tuple in the list indicates, in this order, (a) which kind of candy we are buying, (b) how many pieces of that candy we are buying (which we may assume is positive), and (c) the unit price of that kind of candy. For example, the tuple ('Gum', 15, 0.25) indicates we are buying 15 pieces of gum, which cost $0.25 apiece. The function always returns a floating-point value. A 10% discount is awarded on a particular item if the customer purchases 5 or more of that item. The discount applies to the entire lot of that item. You may assume that all pieces of a particular kind of candy are purchased in a single lot. For example, the list of tuples would not have two or more separate tuples for ' Gum' Important: Do not perform any rounding in your calculations Example # 1: General case candies= [(,Warheads ,, 10, 1.0), ("crunch , , 13, 0.8), ('Snickers,, 3, 1.22), ('Junior Mints', 9, 1.11), ('Mike and Ike', 2, 0.53) ] Return value: 32.07 Example #2: Every item is discounted candies '5th Avenue', 7, 0.78), 'Crunch', 13, 0.75) ('Black Jack', 11, 1.49), Krackel, 7, 0.92), 'Sour Patch Kids', 10, 0.89), 'AirHeads', 8, 0.69)1 Return value: 47.21 Example #3: No items are discounted candies [("Mars', 3, 1.11), ('Abba-zaba,, 3, 1.04), ('Pez', 1, 1.15), (' Junior Mints', 1, 1.4)] Return value: 9.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!