Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can somebody show how to do part E and F the search_anime function and the main() in python please Assignment Overview In this assignment, you

can somebody show how to do part E and F the search_anime function and the main() in python please
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Assignment Overview In this assignment, you will practice with files and error-handling using exceptions. You are not allowed to use the split method. You are not allowed to use any advanced data structure (e.g., Lists, Dictionaries, Classes, etc.). Using any of these will result in a zero. Assignment Background Anime like One Piece, Dragon Ball, and Pokmon have been seen by million of viewers worldwide. AnimePlanet.com is a website which contains records of many anime titles and allows people to review and score them based on popularity, story, animation, etc. This project will read files with these records and address the following questions: (1) What anime title(s) has the highest score? (2) What title(s) have the highest number of episodes? (3) What title(s) have the lowest scores? The files used in this project were adapted from the following source data: https://www,kaggle.com/datasets/vishalmanel0/anime-dataset-2022 Assignment Specifications 1. You must implement the following functions: a) open_file( )fp This function repeatedly prompts the user for a filename until the file is opened successfully. An error message should be shown if the file cannot be opened. It returns a file pointer. Use try-except to determine if the file can be opened. Check the strings. txt file for the appropriate strings to use in the prompt and error message to match the tests. When opening the file, you need to use encoding = "ut f8 ". For example, \[ f p=\text { open ("anime_tiny.txt", "r", encoding="utf-8") } \] b) find_max (value, name, max_value, max_name) float, str: This function returns the value and the formatted name whose value is greater than max value. If value is less than max_value return max_value and max_name. If value is higher than max_value return value and formatted name. Otherwise, concatenate name into max_name and return max_value and max_name. This function is a single comparison between the parameters. Use the following formatting to format the returned strings for names: " \t{" (when retuming a new max name) and " (\\\\l" (when concatenating the name after max_name) i. Input: 1. value (float) Spring 2023 2. name (str) 3. max_value (float) 4. max_name (str) ii. Output: 1. Maximum value (float) 2. Maximum name (str) c) find min (value, name, min_value, min_name) float, str: This function returns the value and name whose value is less than min value. If value is greater than min value return min value and min name. If value is lower than min value return value and formatted name. Otherwise, concatenate name into min_name and retum min_value and min_name. This function is a single comparison between the parameters. Use the following formatting to format the returned strings for names: " \tf" (when retuming one name) and " (1 \t()" (when concatenating the name after min_name) i. Input: 1. value (float) 2. name (str) 3. min value (float) 4. min_name (str) ii. Output: 1. min value (float) 2. min_name (str) d) read_file(data_fp) float, str,float,str,float,str,float This function reads a file with the anime title data. While reading the file, this function finds the highest scoring title, the highest episode count title, and the lowest scoring title. Also computes the average score for all titles in the file. For this project, we are interested in the following columns: title = line [0:100] score = ine [100:105] episodes = line [105:110] When computing the average, round the value to two decimal places. Only consider the anime title's score and episodes that are not " NA " for the max, min, and average computations. For example, if One Piece has a score of 8.66 and episode count is "N/A" (because is still airing), then compute the max score, min score, and average score but do not compute the max episode count evaluation. If the count of scores is 0 (e.g., all scores are N/A), return 0.0 Important: You are required to use string slicing as shown above. Not doing so can affect reading the data from the file. i. Input: 1. fp (File pointer object) ii. Output (return values): 1. max_score (float) 2. max_score_name (str) 3. max episodes (float) 4. max episode name (str) 5. min_score (float) 6. min_score_name (str) e) search_anime (data_fp, search_str) int, str This function reads through a file and returns the title and release season if it contains the search string passed as parameter. Concatenate all the formatted strings of titles and release season, if there are multiple titles that includes the search str. For this project, we are interested in the following columns: \[ \begin{array}{l} \text { title }=1 \text { ine }[0: 100] \\ \text { release_season }=1 \text { ine }[110: 122] \end{array} \] Each entry for title and release season should be formatted using the following string formatting: " (n)t(})t" (first string is the title in a field width of 100 and then release season as a string in a field width of 12) i. Input: 1. data_fp (fe pointer object) 2. search_str (str) ii. Output: 1. count (int): number of titles with the search string 2. out_str (str): Title and release season output string f) main 0 : This function is the starting point of the program. The program prompts the user for an option until the user decides to stop the program: i. Option 1: 1. Prompt the user for a file to open. 2. Call the read file function and receive the max, min, and average values. 3. Display the highest score value and all anime title(s) with the same score. 4. Display the highest number of episodes and all anime title(s) with the same number of episodes. 5. Display the lowest score value and all anime title(s) with the same score. Check the stirings, txt file for the appropriate strings to use to mateh the tests. 6. Close the file. ii. Option 2: 1. Prompt the user for a file to open. 2. Prompt the user for a search string to look for in each title within the file. 3. Call the search anime function and receive the number of titles found with the title and release season of all elements found. 4. Display the results. Check the strings. txt file for the appropriate strings to use to match the tests. 5. Close the file. iii. Option 3: Stop the program. If the user does not enter any of these options, the program needs to display an error message and prompt again until a valid option is selected. Check the strings. txt file for the appropriate strings to use to mateh the tests

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

More Books

Students also viewed these Databases questions

Question

what is the Transitioning to the Agenda in mediation?

Answered: 1 week ago