Answered step by step
Verified Expert Solution
Link Copied!

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 take-home 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 5 operations:
First operation (1) displays the "username"(s) contained in the chosen category. If operation (1) 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 3).
Second operation (2) displays the number of business accounts within the category. This operation basically counts the "True" value of the "is_business_account" feature for the chosen category.
Third operation (3) calculates the average of "following" for the chosen category.
Fourth operation (4) displays the "username" of the account(s) 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 (5) 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 if100_the3.txt, 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.
if100_the3.txt
Column Name
Content
username
Account name/id.
is_business_account
Whether account is a business account or not ("True" if yes else "False")
category_name
Category of the given account (e.g. 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 "category_name", the user will be informed with an error message "'' does not exist." (see sample run 1) and the program will terminate immediately. Input is case-sensitive.
If the entered category is inside of the "category_name" feature, you will be displaying the given instruction:
'''
Please enter your choice:
(1) Get the accounts
(2) Get the count of business accounts
(3) Take the average of the following numbers.
(4) Find account(s) with the highest follower number.
(5) 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 1 and 5, 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 1 to 5." If an error message is displayed, skip a line to make next instructions easy to read.
If the user chooses option 1, 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 non-negative integer. If the user entered an input that is not a non-negative integer, your program should first display an error message "You need to enter a non-negative 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 5 options.
Option (1):
'''
1) username<1>
2) username<2>
...
n) username
'''
Recall that displayed accounts must be alphabetically ordered.
Option (2):
Number of total business accounts: > out of >
Where ">" contains the number of True in "is_business_account" feature for category and ">" contains the number of "is_business_account" feature category.
Option (3):
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions