Help needed with Python 3: Dictionaries and Sets.
The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions.
The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this media fire link: http://www.mediafire.com/folder/qn5fao1hzlxid/Definitions_and_Sets_Data
Thank you in advance for all your help! Please feel free to write in the comment lines to help further my understanding of your proccess!
# Please find the required solution # I have given solution for read_from_file and dump_data # please ask rest of them as separate question import os.path from os import path def read_food_file(filename): dictionary = {} if not path.exists(filename): print(filename, ' doesnot exist') else: food_file = open(filename) entries = food_file.readlines() for line in entries: data = line.rstrip('\n').split(',') dictionary[data[0]] = data[1:] return dictionary def dump_data(eat_data): for key in sorted(eat_data): eat_data[key].sort() print(key, ":", ', '.join(eat_data[key])) def main(): food_file=input('Name of the CSV file? ') eat_data=read_food_file(food_file) dump_data(eat_data) if __name__ == "__main__": main()
Sample output:
food01.csv
jackle,grass,zebra,gazella gazella,acacia leaves,grass lion,gazella zebra,grass
Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...
Assignment: You are to create seven classes that represent a Zoo. The classes are define as follows: 1. Zoo 2. Enclosure 3. Animal 4. Crocodile 5. Gazelle 6. Lion 7. Zebra 1. Zoo: Required member variables: private String name; private String address; private Enclosure[] enclosures; private int area; private double budget; 2. Enclosure: Required member variables: private String biome; private Animal[] animals; 3. Animal Required member variables: private String name; private String genus; private String species; private Zoo currentZoo; protected...
(IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...
I need help on these functions PYTHON 3. The information about the functions is in the first two pics. Scenario The Pokemon franchise consists of over 60 video games, 15 movies, several TV shows, a trading card game, and even a musical. It has been around for over two decades and at this point has fans of all ages. Because of this, people have become somewhat analytical about how they play the games. To help players of the Pokemon video...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
Python Help Please! This is a problem that I have been stuck on.I am only suppose to use the basic python coding principles, including for loops, if statements, elif statements, lists, counters, functions, nested statements, .read, .write, while, local variables or global variables, etc. Thank you! I am using python 3.4.1. ***( The bottom photo is a continuation of the first one)**** Problem statement For this program, you are to design and implement text search engine, similar to the one...
According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...
Python lab: Problem Statement: In this lab, you will be building a software application that will print the most popular ice-cream flavor among kids. Lab Scenario: 1. You are given an input file flavors.txt. One sample example of the file is given below. 2. You will design a user-defined function most_favorite_flavor() which will return the name of the popular flavor. 3. The main function is responsible reading from the file and calling the most_favorite_flavor() function. 4. For this lab, you...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...