Question: Q 1 ) [ 3 . 5 points ] Given a text file food.txt containing the availability of food items. food.txt is structured as follow:
Q points Given a text file food.txt containing the availability of food items. food.txt is structured as follow: the category, name, description, price and availability of a food item, separated by comma Download the data file named food.txt from the Exam Submission on Blackboard simply rightclick on the file name and choose 'Save as 'and browse to your GENG folder and save the file Create a new Python program named
qpy in which you define a main function. Perform the following in the main function:
Open the file, read all the records and store them in a D list called and then close the file.
afind the following:
The details of food with the category Fast food.
The details of food with the lowest price.
mavg which is the average ie the sum of prices divided by the number of food items
b Using list comprehension, create a new list named offer, where each element represents a discounted price; apply a discount of QAR to each food item's price in mdata.
c Sort the offer list in ascending order
d Write all the elements of offer in a file called questiontxt and close the file.
e Count and output the available foods only the available items in the following format: Number of available foods:
Details: name categorydescription: price
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
