A social media star named Finnick wants to examine his Instagram account to determine which photos have received the most likes and comments. He wants to learn which postings receive the most likes, comments, and interactions. He keeps track of the likes and comments received on his Instagram postings. To read this data and determine the interaction for each article, he wants to create a Python programme.
He wants to apply the algorithm below to determine engagement:
Engagement is calculated as (likes + comments) / the number of followers.
To see which posts are performing the best, he also wants to display the posts in descending order of interaction.
Task:
Write a Python program that can read in the list of Instagram posts, calculate the engagement for each post using the formula provided, and display the posts in descending order of engagement.
Your program should have the following functionalities:
Read the list of Instagram posts from a CSV file:
The original input file could not be recovered. This question needs that dataset to reproduce the original exercise.
The CSV file will have two columns: "likes" and "comments". Each row will correspond to one post.
Store the number of followers in a variable called num_followers.
Calculate the engagement for each post using the formula provided and store it in an engagement list.
Display the posts in descending order of engagement and the number of likes, comments, and engagement.