Game statistics reports 2

The story

Judy is very thankful because of your previous work. That is why she asks your help again. She has more questions.

Description (not changed)

Your task is to write reports that answer Judy’s questions. Every report needs to be implemented as a function so every function is related to a question. For every report function you need to write a printer function also. The printer function has to print the return value(s) of the report function.

The input file (not changed)

You can find the input file in the repository. Its name is game_stat.txt.

Every line in the file contains the following information about a game:

  • title
  • total copies sold (million)
  • release date
  • genre
  • publisher

These are the properties of a game. Properties are separated by a tab character and lines are separated by line break characters. You need to pay attention these special characters when you read the file.

The first line: Minecraft⟶23⟶2009⟶Survival game⟶Microsoft

General expectations of the report functions (not changed)

Every report function:

  • has to be named properly (as you see in the Questions section)
  • must NOT contain printing to console
  • returns only the asked information
  • should run in any order
  • has only the parameters predefined in the questions
  • has to be prepared for any other data files (not just the game_stat.txt) within the same structure
  • do NOT import other modules

Expectation of the source code (not changed)

You need to write your project into 3 source files:

  1. reports.py: write only the report functions in it.
  2. printing.py: for printing the output of the report functions in a user friendly way. You can use this to test your solutions.
  3. export.py: for exporting the reports into a single export file. By running this program Judy will get a single text file with all the answers she needs (you should export only the answers line by line, Judy will know the questions).

Judy will run printing.py and export.py to get the answers she want’s, ask her for input where needed (e.g. game title).

Judy’s questions

  1. What is the title of the most played game (i.e. sold the most copies)? Expected name of the function : get_most_played(file_name) Expected output of the function : (string) Other expectation : if there is more than one, then return the first from the file
  2. **How many copies have been sold total? ** Expected name of the function : sum_sold(file_name) Expected output of the function : (number)
  3. **What is the average selling? ** Expected name of the function : get_selling_avg(file_name) Expected output of the function : (number)
  4. **How many characters long is the longest title? ** Expected name of the function : count_longest_title(file_name) Expected output of the function : (number)
  5. **What is the average of the release dates? ** Expected name of the function : get_date_avg(file_name) Expected output of the function : average year (number) Other expectation : the return value must be the rounded up average
  6. What ** **properties has a game? **** Expected name of the function : get_game(file_name, title) Expected output of the function : a list of all the properties of the game (a list of various type). Details : the function get a parameter named game. This is the title of the game (string). This is an existent game. The function return a list of the properties of this game including the title. An example return value: [“Minecraft”, 23.0, 2009, “Survival game”, “Microsoft”].

… and more bonus questions! (nice to have)

Judy knows that you are a very busy programmer, but she has more questions and she looks like a cute little dog with big eyes.

  1. **How many games are there grouped by genre? ** Expected name of the function : count_grouped_by_genre(file_name) Expected output of the function : a dictionary with this structure: { [genre] : [count] } Detailed description : return a dictionary where each genre is associated with the count of the games of its genre
  2. What is the date ordered list of the games? Expected name of the function : get_date_ordered(file_name) Expected output of the function : the date ordered list of the titles in descending order (list of string) Other expectation : The secondary ordering rule is the alphabetical ordering of the titles. So if there are titles from the same year, you need to order them alphabetically in ascending order.

Github Classroom project

You can use the same repository as assignment “Python: Game statistics reports”. There is a directory named “part2”. This is the root directory of this assignment.

You can check your work again by running test.py.

Submission (not changed)

Please submit an URL for a specific commit, made before the deadline. A valid submission url should look something like this:

https://github.com/CodecoolBP/pbwp-3rd-si-game-statistics-mentors_are_cool **/commit/b53b8dee72444451a9fb14a822bdf77a248778d0**

We wish you success! :)

Evaluation

Running the file test.py can suggest you that how many points you’ll get for the “conform to requirements” outcome:

  • 0 pass: -3
  • 1 pass: 0
  • 2 passes: 2
  • 3 passes: 4
  • 4-5 passes: 7
  • 6 passes: **10 ** After all compulsory functions pass we can see the extras:
    • +1 extra: 10
    • +2 extra: 12

We will also check you solution by “hand” to check “clean code”-ness.

Probably, we will test your solution by another input file so your functions must be “universal” for any input file with the same structure as game_stat.txt.

This exercise deepens your Python knowledge, your ability to conform to requirements, and your skill to write clean code.