1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maria [59]
3 years ago
11

Assignment Background Video games have become an outlet for artists to express their creative ideas and imaginations and a great

source of entertainment for people who seek a fun and accessible ways to immerse in unique worlds while also share and interact with others. This project will print video game sales data for various platforms across the years. From the old school consoles like Atari 2600 and Sega Genesis to more modern ones like the Xbox One and PlayStation 4. Project Specifications You must implement the following functions: open_file() → file pointer: a. 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 and FileNotFoundError to determine if the file can be opened. Use the 'utf-8' encoding to open the file. fp = open (filename, encoding ='utf-8') b. Parameters: none c. Returns : file pointer main () : a) This function is the starting point of the program. The program starts by opening the file with the video game sales and reading the data into three dictionaries. The program will repeatedly prompt the user to select an option from the following menu: i. Option 1: Display the global sales for all video game titles across multiple platforms in a single year. Prompt for a year (validation is required!, year needs to be an int), get the data by calling the get_data_by_column function, and then display the selected year's data if the year exists in the data. Prompt the user whether they want to plot the data. If the answer is "y", use plot_global_sales ( ) to plot the histogram of the total global sales per publisher. ii. Option 2: Display the global sales for all video game titles across multiple years in a single platform. Prompt for a platform (validation is required!, cannot be a number) ), get the data by calling the get_data_by_column function, and then display the selected platform data if the platform exists in the data. Prompt the user whether they want to plot the data. If the answer is "y", get lists to plot by calling the get_totals function, and then use plot_global_sales () to plot the histogram of the total global sales per year. iii. Option 3: Display the regional sales for all video game genres. Prompt for a year (validation is required!, year needs to be an int), call get_genre_data, and then display the selected year data if the year exists using display_genre_data. Prompt the user whether they want to plot the data. If the answer is "y", call prepare_pie to get the lists to plot, and then use plot_genre_pie () to plot a pie chart of the total global sales per genre. iv. Option 4: Display the regional sales for all the video games by publisher. Prompt the user for a keyword in the publisher. Search for all publishers who have that keyword as a substring, then display the results. If there are multiple publisher names with the same string, enumerate all possible names. The publisher names should appears alphabetically because they were read into the dictionary that way; if not, sort them. Use the following string formatting: "{:<4d}{}", format (index, publisher) " Your header goes here import csv import pylab from operator import itemgetter def open_file(): WRITE DOCSTRING HERE! pass def read_file(fp): WRITE DOCSTRING HERE! pass def get_data_by_column (D1, indicator, c_value): WRITE DOCSTRING HERE! pass def get_publisher_data (D3, publisher): WRITE DOCSTRING HERE! pass def display_global_sales_data(L, indicator): WRITE DOCSTRING HERE! header1 = ['Name', 'Platform', 'Genre', 'Publisher', 'Global Sales'] header2 = ['Name', 'Year', 'Genre', 'Publisher', 'Global Sales'] pass def get_genre_data(D2, year): WRITE DOCSTRING HERE! pass def main(): # Menu options for the program MENU = '''Menu options 1) View data by year 2) View data by platform 3) View yearly regional sales by genre 4) View sales by publisher 5) Quit Enter choice: ". while choice != '5': #Option 1: Display all platforms for a single year try: #if the list of platforms for a single year is empty, show an error message pass except ValueError: print("Invalid year.") #Option 4: Display publisher data # Enter keyword for the publisher name # search all publisher with the keyword match = [] # print the number of matches found with the keywords if len (match) > 1: print("There are {} publisher(s) with the requested keyword!".format(len(match))). for i,t in enumerate (match): print("{:<4d}{}".format(i,t[0])) # PROMPT USER FOR INDEX else: index = 0 choice = input (MENU) print("\nThanks for using the program!") print("I'll leave you with this: "All your base are belong to us!"") if == "_main ": name main()

Computers and Technology
1 answer:
Sphinxa [80]3 years ago
7 0

Answer:

Code

import csv

def open_file():

try:

fname=input("Enter the filename to open (xxx.yyy): ")

fp=open(fname,encoding='utf-8')

return fp

except FileNotFoundError:

print("File not found! Please Enter correct filename with extension")

return open_file()

def read_file(fp):

fields = []

rows = []

csvreader = list(csv.reader(fp))

# skiped 1 row because it contains field name

fields = csvreader[0]

D1={}

D2={}

D3={}

# accessing the data of csv file

for line in csvreader[1:]:

name = line[0].lower().strip()

platform = line[1].lower().strip()

if line[2]!='N/A':

year = int(line[2])

else:

year=line[2]

genre = line[3].lower().strip()

publisher = line[4].lower().strip()

na_sales = float(line[5])

eur_sales = float(line[6])

jpn_sales = float(line[7])

other_sales = float(line[8])

global_sales=(na_sales+eur_sales+jpn_sales+other_sales)*1000000

if name not in D1:

D1[name]=[]

D1[name].append((name, platform, year, genre, publisher,global_sales))

if genre not in D2:

D2[genre]=[]

D2[genre].append((genre, year, na_sales, eur_sales,jpn_sales, other_sales, global_sales))

if publisher not in D3:

D3[publisher]=[]

D3[publisher].append((publisher, name, year, na_sales,eur_sales, jpn_sales, other_sales, global_sales))

# sorting

temp={}

# sorting keys

for Keys in sorted (D1) :

ls=D1[Keys]

ls=sorted(ls,key=lambda x: x[-1]) # sorting values

temp[Keys]=ls

D1=temp.copy()

temp={}

# sorting keys

for Keys in sorted (D2) :

ls=D2[Keys]

ls=sorted(ls,key=lambda x: x[-1]) # sorting values

temp[Keys]=ls

D2=temp.copy()

temp={}

# sorting keys

for Keys in sorted (D3) :

ls=D3[Keys]

ls=sorted(ls,key=lambda x: x[-1]) # sorting values

temp[Keys]=ls

D3=temp.copy()

return D1,D2,D3

 

def main():

fp=open_file()

D1,D2,D3=read_file(fp)

# displaying the row_count in dictionaries

cnt=0

for d in D1:

cnt+=1

print(cnt)

print("\n\n=============================================\n\n")

cnt=0

for d in D2:

cnt+=1

print(cnt)

print("\n\n=============================================\n\n")

cnt=0

for d in D3:

cnt+=1

print(cnt)

print("\n\n=============================================\n\n")

 

 

if __name__=="__main__":

main()

Explanation:

see code and see output attached

You might be interested in
A network technician is planning to update the firmware on a router on the network. The technician has downloaded the file from
zhenek [66]

Answer: B. Perform a hash on the file for comparison with the vendor’s hash.

Explanation:

Before installing the firmware update, the step that the technician should perform to ensure file integrity is to perform a hash on the file for comparison with the vendor’s hash.

Hashing refers to the algorithm that is used for the calculation of a string value from a file. Hashes are helpful in the identification of a threat on a machine and when a user wants to query the network for the existence of a certain file.

5 0
3 years ago
Adam receives an email from his bank telling him there is a problem with his account. The email provides instructions and a link
Georgia [21]

Answer:

2 and 3

Explanation:

fill out all details because the email looks authentic

call the bank to determine if he email is authentic

hope this helps

8 0
2 years ago
Read 2 more answers
Suppose two computers (A &amp; B) are directly connected through Ethernet cable. A is sending data to B, Sketch the waveform pro
ICE Princess25 [194]

Answer:

Physical / Data link layer

Explanation:

If two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, the data would be transmitted if the network is clear but if the network is not clear, the transmission would wait until the network is clear.

The Open Systems Interconnection model (OSI model) has seven layers each with its own function.

The physical layer is the first layer responsible for data transmission over a physical link. The data packets are converted to signals over a transmission media like ethernet cable.

The data link layer is the second layer in the OSI layer responsible for transmission of data packets between nodes in a network. It also provides a way of detecting errors and correcting this errors produced as a result of data transmission.

4 0
3 years ago
Who invented the balloons?
Alexandra [31]
<span>Professor Michael Faraday</span>
6 0
3 years ago
Read 2 more answers
_____________technique can be used to create smooth animations or to display one of severalimages based on the requirement.
kozerog [31]

Answer: Image preloading

Explanation:

The Image Preloading process  can be describes as follows:

1. Using the new keyword an instance of the image object is created.

2. The src property and the flename of the image is set be equal.

3. Then image is downloaded into the cache with displaying it.

4. The src property is set equal to the prefetched image when it is required to display the image.

3 0
3 years ago
Other questions:
  • Int, char, bool, and double are all valid data types in c , true or false
    15·1 answer
  • Which is a safe Internet behavior?
    5·1 answer
  • What is the name of the interface that uses graphics as compared to a command-driven interface?
    11·1 answer
  • Where can I learn how to make my own video game for free?
    6·2 answers
  • Which approach to knowledge management capitalizes on tacit knowledge and requires heavy IT investment?
    7·1 answer
  • (2) Design pseudocode for a program that accepts numbers from the user until the special number 555 is entered (you should use a
    12·1 answer
  • Designers and graphic artists can print finished publications on a color printer, take them to a professional printer, or post t
    15·1 answer
  • Which best explains a password attached to a document?
    7·1 answer
  • Write a java code to print Multiplication Table Till 20
    14·2 answers
  • What special enterprise VPN supported by Cisco devices creates VPN tunnels between branch locations as needed rather than requir
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!