Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction The aim of this homework is to practice file operations and dictionaries. Description In this take - home exam, given a social media database,
Introduction
The aim of this homework is to practice file operations and dictionaries.
Description
In this takehome exam, given a social media database, your task is to create an analysis tool that offers several choices for the user. Based on the selected option, the program will analyze the data and display the results.
The program will prompt the user to select a category for analysis. It will then check whether the chosen category exists in the database. If it exists, the program will prompt the user to choose the operation that will be performed.
There are operations:
First operation displays the "username"s contained in the chosen category. If operation is chosen, the user will be prompted to select the threshold for the number of accounts to display. Displayed users must be alphabetically sorted see sample run
Second operation displays the number of business accounts within the category. This operation basically counts the "True" value of the isbusinessaccount" feature for the chosen category.
Third operation calculates the average of "following" for the chosen category.
Fourth operation displays the "username" of the accounts with the highest follower number within the chosen category. Keep in mind that you will be displaying "username"s in an alphabetical order.
Fifth operation will display the counts of Influencer and Company labels that are contained within the "class" feature for the chosen category. Count of Influencer will be shown first all the time.
To this end, you will be working with the provided file ifthetxt where each line represents information regarding a single account. Each piece of information regarding an account is separated by space equal sign, underscore, underscore, equal sign, space as described below. The first line of the file contains the columns' names, so its the header line.
ifthetxt
Column Name
Content
username
Account nameid
isbusinessaccount
Whether account is a business account or not True if yes else "False"
categoryname
Category of the given account eg Public figure, Musician, Brand
followers
Number of followers that the account has
following
Number of followings that the account has
class
Label of accounts. Can be either "Influencer" or "Company"
Inputs
You will first prompt the user to choose the category with an input message "Please enter the category: If the user has entered a category that is not inside of the "categoryname", the user will be informed with an error message does not exist." see sample run and the program will terminate immediately. Input is casesensitive
If the entered category is inside of the "categoryname" feature, you will be displaying the given instruction:
Please enter your choice:
Get the accounts
Get the count of business accounts
Take the average of the following numbers.
Find accounts with the highest follower number.
Count the labels
After you display the message, you will prompt the user to enter a choice with an input message "Your choice: If the user entered an input that is not an integer between and your program should keep asking the same input with provided instructions as long as the user enters the correct input. If the user enters an incorrect input, the program should inform the user by displaying an error message "You need to enter a number from to If an error message is displayed, skip a line to make next instructions easy to read.
If the user chooses option you will be getting another input from the user to select the threshold for the number of accounts to display with an input message "Please enter the number of accounts to show: The input must be a nonnegative integer. If the user entered an input that is not a nonnegative integer, your program should first display an error message "You need to enter a nonnegative integer." and keep asking the same input as long as the user enters the correct input.
Output
Once you have the correct inputs, then, you are going to display one of the outputs for provided options.
Option :
username
username
n username
Recall that displayed accounts must be alphabetically ordered.
Option :
Number of total business accounts: out of
Where contains the number of True in isbusinessaccount" feature for category and contains the number of isbusinessaccount" feature category.
Option :
Average number of followings for is:
Where is the chosen category by the user and
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started