0% found this document useful (0 votes)
6 views1 page

Python Grade and Word Analysis Tasks

The document outlines two programming tasks involving file handling in Python. The first task requires reading student grades from a file, calculating their average scores, and writing the results to a new file. The second task involves counting word frequencies from a text file and saving the results in a separate file, both with specific formatting requirements.

Uploaded by

dibyarayart
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Python Grade and Word Analysis Tasks

The document outlines two programming tasks involving file handling in Python. The first task requires reading student grades from a file, calculating their average scores, and writing the results to a new file. The second task involves counting word frequencies from a text file and saving the results in a separate file, both with specific formatting requirements.

Uploaded by

dibyarayart
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BASIC PYTHON TEST

You are given a text file [Link] where each line contains a student's name and their scores in
multiple subjects, separated by commas.
Example file content:

Alice,88,76,92

Bob,90,85,79

Charlie,95,80,85

Task:

• Read the file and store the data in a dictionary where the key is the student's name, and the
value is a list of their scores.

• Write a function calculate_average(grades: list) -> float to calculate the average.

• Display each student’s name along with their average score.

Bonus:

• Write the result to a new file [Link] in this format:

Alice: 85.33

Bob: 84.67

Charlie: 86.67

Question 2: Word Frequency Counter

Problem Statement:

Write a program that reads a text file [Link] and calculates the frequency of each word in the file.

Task:

• Use a dictionary to count how many times each word appears (ignore punctuation and case).

• Use a function get_word_frequency(filename: str) -> dict that returns the frequency
dictionary.

• Sort and print the top 5 most frequent words.

Bonus:

• Save the frequency dictionary into a new file [Link] in descending order.

You might also like