Comp 151 Project 4

Display some Data from a file

Summary:

In this 4th project you will open a file, and create a very simple visualization, practicing  arcade, files, lists, if statements and loops.

Due:

 Oct 21,  2022 at 11:59pm

Description:

First create a new project (which creates a new project folder) – use the naming convention from the “Additional Requirements” section below. (include your name and something identifying this as project4)

  1. Download the file nationsPop.txt into your project
  2. open the file and read all of the lines into a list of lines The file is a comma separated list
    1. each line is in the format
      country name,country pop,percentage change
      eg:
      Nigeria,218541212,2.41
      Means that Nigeria has a population of 219 hundred million people and a growth rate in the last year of 2.41%
  3. Open an arcade window, and show it on the screen (the whole run, strart_render etc)
  4. Draw the Title of the graph
  5. draw the x-axis
    1. label the x-axis (see below in item 7, if the nation titles don't line up perfectly that is ok)
  6. draw the y-axis
    1. label it
  7. For each line in the file.
    1. split the line on the comma
    2. you will draw a bar representing the population of this country for each line in the file
      1. if the percentage change is negative draw the bar in one color
      2. in the percentage change is positive draw the bar in another color.
    3. draw the country name in the correct spot below the x-axis
    4. draw the bar the correct height and color over the county name
      1. if you make your graph look like mine, I found the bar height using this math:
      2. bar_height = (int(nation_data[1])-100_000_000)/1_000_000
      3. where nation_data was my split line. I remove 100 million because that is the bottom value in the graph, then I divide the rest by one million so that I keep the population value usable.
  8. I will try your solution with both the 2022 data that I gave to you here and with the 2021 data to make sure that your program is working from the file and not just drawing a picture.

Sample output.

When I ran my solution on the provided nationsPop.txt File, I had this output.

Instructor demo of project 4

Additional  requirements:

Your code must be commented


To help me identify your work, make the name of your project

yourFirstInitialLastNameProject4

(so mine would be JSantoreProject4)
And put the following at the beginning of the program as a comment:



Project Submission

Submit the project by putting it on github as a private project and making me a collaborator as before.