Answer in python
Task 7: Write the preferred laptop details to a file
Write a function named record preferred(table, output filename='preferred laptops.txt') that writes the details of the preferred laptops, into the given text file, output f ilename. Note that the input parameter, table is the output of task 6 above.
Add the title "Preferred Laptop Details" as the first line in the file. Add the column headers: Laptop ID,Company, Product, Type name, Screen size, RAM, Operating System, Weight and Price (separated by commas) in the next line. Then add the details of preferred laptops you have identified in task 6 above, with one line per laptop (each field separated by commas).
Input: A table containing all the data that is available in the given data file with the preferred column appended. Output: The given file updated with the details of the preferred laptops.
For example: >>> laptops_data = read_data('laptop_dataset.txt') >>> preferred_laptops (laptops_data) >>> record preferred(table,'preferred laptops.txt')