ICA9
.pdf
keyboard_arrow_up
School
University of Florida *
*We aren’t endorsed by this school
Course
2273
Subject
Computer Science
Date
Apr 30, 2024
Type
Pages
2
Uploaded by aidanhenriksen
COP 2273 Python Programming for Engineers Individual Coding Assignment 9 (ICA9): Dictionaries Create a Python program that reads the provided csv file (world_cup_champions.csv) that contains a list of FIFA World Cup champions and determines the country that has won the most championships as shown in the test case. Specifications
•
When your program starts, it should read the csv file called “
world_cup_champions.csv
” and use a dictionary to store the required data using the name of each country that has won the World Cup as the key. If an invalid filename is entered, your program should keep asking until a valid filename is entered. •
Your program should compile the data and display the countries alphabetically as shown in the test case.
COP 2273 Python Programming for Engineers Individual Coding Assignment 9 (ICA9): Dictionaries •
At the top of your file, your program must include a file name, short description of the program, and your name as Python comments.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
PYTHONPLEASE ALSO SHARE CODE THROUGH LINK: online-python(dot)comAlso screenshot code with correct indentation
Create a python program that reads the student information from a tab separated values (tsv) file. The python program then must creates a text file that will records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midtrm1 score, Midtrm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfoScore.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user.
Open the tsv file and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90 =< x
B: 80 =< x < 90
C: 70 =< x < 80
D: 60 =< x < 70
F: x < 60
Compute the average of each exam.
Output the…
arrow_forward
Part B - reading CSV files
You will need a Python repl to solve part B.
Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US
government showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format
Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code
The data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers.
Your function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's
value should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1).
Important Hints:
* You will really, really want to use the built-in csv…
arrow_forward
PYTHONPLEASE ALSO SHARE CODE THROUGH LINK: online-python(dot)com
Create a python program that reads the student information from a tab separated values (tsv) file. The python program then must creates a text file that will records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midtrm1 score, Midtrm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfoScore.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user.
Open the tsv file and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90 =< x
B: 80 =< x < 90
C: 70 =< x < 80
D: 60 =< x < 70
F: x < 60
Compute the average of each exam.
Output the last names, first names, exam scores, and letter…
arrow_forward
In python please! I am struggling
arrow_forward
return_dict() that takes the name of a CSV file as the input parameter and returns a dictionary, where each key is the Reporting_PHU_ID and the value is a list containing the following data.
name of CSV file is "data23.csv"
arrow_forward
8. Name and Email Addresses
Write a program that keeps names and email addresses in a dictionary as key-value pairs. The program should display a menu that lets the user look up a person’s email address, add a new name and email address, change an existing email address, and delete an existing name and email address. The program should pickle the dictionary and save it to a file when the user exits the program. Each time the program starts, it should retrieve the dictionary from the file and unpickle it.
arrow_forward
Create a structure called applianceTvpe with the following members. Use the
proper variable TYPES for the members:
name;
SUpplierlD:
modelNo:
cost;
Create an array variable of type applianceType that can hold 50 components.
Write the code segment to read from a file into the structure array. Declare an
input file stream identifier for this purpose. Open the file and read until end of file.
Keep a count of how many rows actually read. The data file contains the following
data:
RefrigeratorABC 80 4657 521.62
ToasterOven 100 3245 245.96
MicroWave 95 7878 345.67
Using a looping construct, output to the console (cout) the data read into the
structure array. Make sure you do not go outside the bounds of the array or
beyond the number of rows actually read.
You do not need to write any #include statements, using statements and you do
not have to write code to open the file. Assume the file is open.
You do need to declare variables needed for the program segment.
arrow_forward
IN C++
Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements:
Each row contains the title, rating, and all showtimes of a unique movie.
A space is placed before and after each vertical separator ('|') in each row.
Column 1 displays the movie titles and is left justified with a minimum of 44 characters.
If the movie title has more than 44 characters, output the first 44 characters only.
Column 2 displays the movie ratings and is right justified with a minimum of 5 characters.
Column 3 displays all the showtimes of the same movie, separated by a space.
Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows.
Hints: Use the find() function to find the index of a comma in each…
arrow_forward
def import_and_create_bank(filename): ''' This function is used to create a bank dictionary. The given argument is the filename to load. Every line in the file should be in the following format: key: value The key is a user's name and the value is an amount to update the user's bank account with. The value should be a number, however, it is possible that there is no value or that the value is an invalid number.
What you will do: - Create an empty bank dictionary. - Read in the file. - Add keys and values to the dictionary from the contents of the file. - If the key doesn't exist in the dictionary, create a new key:value pair. - If the key does exist in the dictionary, increment its value with the amount. - You should also handle the following cases: -- When the value is missing or invalid. If so, ignore that line and don't update the dictionary. -- When the line is completely blank. Again, ignore that line and don't update the…
arrow_forward
In python:
you will be building a software application that will print the most popular ice-cream flavor among kids.:
1. You are given an input file ‘flavors.txt’. One sample example of the file is given below.2. You will design two user-defined function apart from main:3. create_flavor_dict(lines): takes the file information and creates a flavor count dictionary where key will be a ice-cream flavor and value will be the count of how many times children had that particular flavor.4. most_popular_flavor(flavor_dict): returnsthe name ofthe popular flavorfrom the flavor_dict.5. The main() function isresponsible reading from the file information and calling the two functions function.6. You MUST use a dictionary data structure to determine the count of each flavor. You then determine the most popular flavor from the dictionary values.
arrow_forward
Word Puzzle GameIn this assignment is only for individual. You are going to decode the scrambled word into correct orderin this game. One round of play is as follows:1. Computer reads a text file named words.txt2. Computer randomly picks one word in the file and randomly scrambles characters in the wordmany times to hide the word3. Computer displays the scrambled word to user with indexes and gives the user options to1. Swap two letters in word based on index given2. Solve the puzzle directly3. Quit the game4. If a player chooses to swap letters, the computer reads two indexes and swaps the letters. Thegame resume to step 3 with the newly guessed word. If the resulted word after swapping is thesecret word, the game is over.5. If a user chooses to solve directly, computer prompts the user to enter the guessed word. If it’scorrect, the game is over, otherwise goes to step 3.6. After game is over, display how many times the player has tried to solve the puzzle.The following is sample…
arrow_forward
Print Person Information from file
In this lab you are asked to complete the function : print_person_from_file(person_name, filename). This function should
read in data from the file filename and print the information for person_name if it is found in the file.
The file filename contains lines, in comma separated format (with a 'csv' extension) For each line, the items in each field are as follows:
Field
1
3
4
Name
Place of Birth Date of Birth Children
For Children:
• a person can have 0, 1 or multiple Children
Multiple children are semi-colon separated
If a person has no children the field contains 'NA'
For example, consider the following lines froma .csv file, where Fletcher_Margaret has 3 children, and Baker_Jill has 0 children
(field 4 contains the string 'NA')
Fletcher Margaret,Sydney,30-09-1921,Green Bob;Green Nancy;William Tom
Baker_Jill, Melbourne,08-09-1973, NA
Format for Printing
If the person_name is found in the file, the format for printing the person information is as…
arrow_forward
Programming language is C#
arrow_forward
Overview
This program will welcome a user to the trivia builder 3000, then prompt the user to add questions to the trivia bank. After the user indicates they are done it will print out the contents
of the trivia bank.
Expected Output
Example 1
Welcome to the trivia builder 3000
Enter the next question: Who was the fifth Beatle?
Enter the correct answer for that question: Pete Best
Enter the next question:
You did not enter a question, let's try again.
Enter the next question: How many dimples does a golf ball have
Enter the correct answer for that question: 336
Enter the next question: Done
We will stop entering questions now
Here is the final trivia dictionary:
The question is: Who was the fifth Beatle?
And the answer is: Pete Best
The question is: How many dimples does a golf ball have?
And the answer is: 336
Example 2
Welcome to the trivia builder 3000
Enter the next question: What was the first name for the Beatles?
Enter the correct answer for that question: The Quarymen
Enter the…
arrow_forward
Program a python program that demonstrates reading and comparing
Create a python program that demonstrates reading and comparing multiple files, processes the input files based on the business rules, and produces an output file.
Needed Files
1. The timeclock.txt Download timeclock.txtfile contains the hours worked data for every employee as well as the shift they worked. The layout for the file is as follows: EMPLOYEE_NUMBER, HOURS_WORKED, SHIFTTimeclock.txt
22476, 45, 3
24987, 30, 148283, 50, 285437, 25, 3
2. The personnel.txt Download personnel.txtfile contains the names of all employees and their hourly pay rates. The layout for the file is as follows: EMPLOYEE_NUMBER, EMPLOYEE_NAME, PAY_RATEPersonnel.txt
11235, Bob Smith, 10.50
22476, John Roberts, 12.3524987, Mary Johnson, 15.9032743, Brad Carson, 11.2548283, Alice Martin, 14.2085437, Aaron James,15.15
Note: Both the timeclock.txt and payroll.txt files are pre-sorted by EMPLOYEE_NUMBER in ascending order.
Business…
arrow_forward
C++ Visual Studio 2019
Write a program that opens a specified text file then displays a list of all the unique words found in the file.
Addition to the text book specifications, print the total of unique words in the file.
Hint: Store each word as an element of a set.
Note: Save text below as the file to use and name it forChap12.txt file for this assignment.
Text: No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia,…
arrow_forward
The file, Program11.txt, on the I: drive contains a chronological list of the World Series’ winning teams from 1903 through 2018. The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2018. (Note that the World Series was not played in 1904 or 1994. There are no entries in the file indicating this.) Write a program that reads this file and creates a dictionary in which the keys are the names of the teams and each key’s associated value is the number of times the team has won the World Series. The program should also create a dictionary in which the keys are the years and each key’s associated value is the name of the team that won that year. The program should prompt the user for a year in the range of 1903 through 2018. It should thendisplay the name of the team that won the World Series that year and the number of times that team has won the World Series.Allow the user to run the program as many times as possible…
arrow_forward
All code in JAVASCRIPT
Write a program that creates two files with the names file4 and file4a
two 10 element int arrays with the names arrfile4 and arrfile4a; these arrays are to have different values
write the contents of arrfile4 to file4write the contents of arrfile4a to file4a
arrow_forward
Computer science
arrow_forward
Word FrequencyWrite a python program that reads the contents of a text file. The program should create a dictio-nary inwhich the keys are the individual words found in the file and the values are the number of timeseach word appears. For example, if the word “the” appears 128 times, the dictionary wouldcontain an element with 'the' as the key and 128 as the value. The program should eitherdisplay the frequency of each word or create a second file containing a list of each word and itsfrequency.
arrow_forward
String data type is not allowed you can make use of CString instead (char arrays with null termination).
Q1. Create an Input File with the following information regarding to inventory:
Item_Id Price Quantity Availability
Add atleast 10 records in input file.
Where item_id will be of type int , price will be of type double , quantity will be of type int and Availability will be of type char representing the status y for yes the product is available and n for not available.
Write a menu driven C++ program to perform the following four tasks in a single file, if user press option 1 the task 1 get solved and so on:
1. Display the Item_Id of the products which are not available in stock on screen.
2. Copy all the available products data in a separate file.
3. Read the original input file and update the price of each item by 10 percent increase in the original price and save the complete information in separate file.
4. Try to save the information processed in part 3 in the original…
arrow_forward
Python code
arrow_forward
Using C++ Language
Create a file called input9B.txt and type (or copy) the following text exactly as it appears below into that file. You may cut and paste the following 7 blue lines (including the blank line between the two paragraphs) into that file: C++ is a cross-platform language that can be used to create high-performance applications. C++ was developed by Bjarne Stroustrup, as an extension to the C language. C++ gives programmers a high level of control over system resources and memory. C++ is one of the world's most popular programming languages. C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems. C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs.
Compile and run the program, using the input9B.txt file as the input file. Did this program produce the same exact output as shown above? What do you think the problem is? The problem is…
arrow_forward
Write C program language
Department of computer science offers a set of courses each
semester. These courses are listed in a file as follows: course
name, course id, number of registered student, and max number
of students. Number of registered students is initialized to zero
always. The file that contains the courses’ information is formatted
as follows (i.e. sample course file): Each semester, students are
required to register a set of courses. The students are listed in a
file along with the courses to be registered as follows: student
name, student id, courses to be registered (COMP242,
COMP336, COMP231...). The file that contains the students’
information is formatted as follows (i.e. sample student file):
Course File
Java#COMP231#0#27 Data Structures #COMP2321#0#30
Algorithms#COMP336#0#15 Computer and
Programming#COMP142#0#27
Student File
Ahmad
Ali#1159999#COMP242#COMP336#COMP231#COMP338 Ali
Mahmoud#1169999#COMP142#COMP336#COMP231
Ashraf Hasan…
arrow_forward
Data structures
dict_from_string(dict_str:str)->dict
This function will be given a single parameter, a string representing a dictionary. Your job is to convert the string into an actual dictionary and return the dictionary. Make sure all key-value pairs in the string exist in the newly created dictionary. The string will contain only numbers or single letters as key values pairs. Make sure all letters are kept as strings and all numbers are converted to integers in the newly created dictionary.
Example:
String Input: '{9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}'
Expected: {9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}
String Input: '{10: 'D', 1: 'Z', 5: 'a'}'
Expected: {10: 'D', 1: 'Z', 5: 'a'}
String Input: '{'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}'
Expected: {'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}
String Input: '{3: 'D', 10: 'T', 7: 'm', 'u': 9, 't': 5, 6: 'Z', 'H': 10, 'B':…
arrow_forward
Python - Next Birthdate
In this task, we will write a program that reads birthdate data from a given CSV file, and given the current date, determines which person's birthday will be celebrated next.
Create a function with the following signature:
nextBirthdate(filename, date)
filename: parameter, which represents the CSV filename.
date: parameter, which represents the current date.
The function should open the CSV file, read the birthdate data, and determine which person's birthday will be celebrated next, given the current date. The name of the person should be returned. In other words, given a date, find the person whose birthday is next.
Sample Run
birthdates.csv
Draven Brock, 01/21/1952
Easton Mclean, 09/02/1954
Destiny Pacheco, 10/10/1958
Ariella Wood, 12/20/1961
Keely Sanders, 08/03/1985
Bryan Sloan,04/06/1986
Shannon Brewer, 05/11/1986
Julianne Farrell,01/29/2000
Makhi Weeks, 03/20/2000
Lucian Fields, 08/02/2018
Function Call
nextBirthdate("birthdates.csv", "01/01/2022")
Output…
arrow_forward
C++: Matching Program
Create a datafile that contains the first name, last name, gender, age, height, smoking preference, eye color and phone number. Add a variety of records to the file. A sample file looks like:
Write a program that opens the file and reads the records one by one. The program will skip any records where the gender preference is not a match. Of those records that match the gender preference, check to see if the age and height are between the maximum and minum preferences. Then check to see if the smoking preference and eye color are also a match. If at least 3 of the remaining fields match, consider the record a partial match, and print it in the report. If all 4 of the remaining fields match, the record is a perfect match and print it in the report with an asterisk next to it. At the end of the program, close the file and report how many total records there were of the specified gender, how many were a partial match, and how many were a perfect match. See the…
arrow_forward
Data File:
Example #1AAAAABBBBBCCCCCDDDDDAAEBCBAFBBCDCECDADDEFEEFFFExample #2AAATAABTBBBBCCCCTCDDTDDDAASAABBSBBCCSCCDSDDDEEEAEEFBFFFDDF
Write a program that will give the user a brief introduction, then allow the user to type in the name of the file to be analyzed, the name of the data file to generate, and then process the data to match the output that is shown below.
This DNA test measures the various parts of the sequence and assigns them a letter. While the letters could be anything from A to Z, the only letters that matter for this test are the letters {A,B,C,D} all other letters can be ignored completely. A sample will be tested, given a length of time and then tested again. Each time the scientist will generate a line of data. Here is one Example: Example #1 AAAAABBBBBCCCCCDDDDD AAEBCBAFBBCDCECDADDEFEEFFF At first glance the sample looks significantly different after the second test. But if you look at the data, you will note that since we only care about A,B,C,D’s that the…
arrow_forward
Please help with my C++Specifications
• For the view and delete commands, display an error message if the user enters an invalid contact number.
• Define a structure to store the data for each contact.
• When you start the program, it should read the contacts from the tab-delimited text file and store them in a vector of contact objects.
•When reading data from the text file, you can read all text up to the next tab by adding a tab character ('\t') as the third argument of the getline() function.
•When you add or delete a contact, the change should be saved to the text file immediately. That way, no changes are lost, even if the program crashes later
arrow_forward
In Java Oleae nust read a file
A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names.
Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output.
Ex: If the input of the program is:
ParkPhotos.txt
and the contents of ParkPhotos.txt are:
Acadia2003_photo.jpg AmericanSamoa1989_photo.jpg BlackCanyonoftheGunnison1983_photo.jpg CarlsbadCaverns2010_photo.jpg CraterLake1996_photo.jpg GrandCanyon1996_photo.jpg IndianaDunes1987_photo.jpg LakeClark2009_photo.jpg…
arrow_forward
GRADEBOOK PROJECT
Attached Files: Gradebook.docx (18.278 KB)
Gradebook Practicla Project: use the attached code as an exaple and modify where neccesary to fit your situation
Write a program that uses an array of string objects to hold the five student names, an array of five characters to hold the five students' letter grades, and five
arrays of four doubles to hold each student's set of test scores.
The program should allow the user to enter each student's name and his or her four test scores. It should then calculate and display each student's ayerage test
score and a letter grade based on the average.
Input Validation: Do not accept test scores less than 0 or greater than 100.
Use the following test score grades
Test Score Letter Grade
80-100 -> A
70-79 -> B
60-69 -> C
50-59 -> D
OO
HUAWEI P30 lite
TRIPLE CAMERA
Activate Windows
dolto vers
arrow_forward
For C++
arrow_forward
Please create your own short dictionary.txt file to test out the functions
arrow_forward
python function that creates and saves data in a file. the saved data represents exam grades. in the function , you will create n random numbers in the range 1-100, where n is the number of students. The function can be called as follows: createFile(filename, n)
main function, in which the user inputs the file name and the number of students, then the main calls function createfile. the main should preform validation for n (should be > 0), and the filename(should end with .txt)
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Related Questions
- PYTHONPLEASE ALSO SHARE CODE THROUGH LINK: online-python(dot)comAlso screenshot code with correct indentation Create a python program that reads the student information from a tab separated values (tsv) file. The python program then must creates a text file that will records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midtrm1 score, Midtrm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfoScore.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the…arrow_forwardPart B - reading CSV files You will need a Python repl to solve part B. Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US government showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code The data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers. Your function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's value should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1). Important Hints: * You will really, really want to use the built-in csv…arrow_forwardPYTHONPLEASE ALSO SHARE CODE THROUGH LINK: online-python(dot)com Create a python program that reads the student information from a tab separated values (tsv) file. The python program then must creates a text file that will records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midtrm1 score, Midtrm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfoScore.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam scores, and letter…arrow_forward
- In python please! I am strugglingarrow_forwardreturn_dict() that takes the name of a CSV file as the input parameter and returns a dictionary, where each key is the Reporting_PHU_ID and the value is a list containing the following data. name of CSV file is "data23.csv"arrow_forward8. Name and Email Addresses Write a program that keeps names and email addresses in a dictionary as key-value pairs. The program should display a menu that lets the user look up a person’s email address, add a new name and email address, change an existing email address, and delete an existing name and email address. The program should pickle the dictionary and save it to a file when the user exits the program. Each time the program starts, it should retrieve the dictionary from the file and unpickle it.arrow_forward
- Create a structure called applianceTvpe with the following members. Use the proper variable TYPES for the members: name; SUpplierlD: modelNo: cost; Create an array variable of type applianceType that can hold 50 components. Write the code segment to read from a file into the structure array. Declare an input file stream identifier for this purpose. Open the file and read until end of file. Keep a count of how many rows actually read. The data file contains the following data: RefrigeratorABC 80 4657 521.62 ToasterOven 100 3245 245.96 MicroWave 95 7878 345.67 Using a looping construct, output to the console (cout) the data read into the structure array. Make sure you do not go outside the bounds of the array or beyond the number of rows actually read. You do not need to write any #include statements, using statements and you do not have to write code to open the file. Assume the file is open. You do need to declare variables needed for the program segment.arrow_forwardIN C++ Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Hints: Use the find() function to find the index of a comma in each…arrow_forwarddef import_and_create_bank(filename): ''' This function is used to create a bank dictionary. The given argument is the filename to load. Every line in the file should be in the following format: key: value The key is a user's name and the value is an amount to update the user's bank account with. The value should be a number, however, it is possible that there is no value or that the value is an invalid number. What you will do: - Create an empty bank dictionary. - Read in the file. - Add keys and values to the dictionary from the contents of the file. - If the key doesn't exist in the dictionary, create a new key:value pair. - If the key does exist in the dictionary, increment its value with the amount. - You should also handle the following cases: -- When the value is missing or invalid. If so, ignore that line and don't update the dictionary. -- When the line is completely blank. Again, ignore that line and don't update the…arrow_forward
- In python: you will be building a software application that will print the most popular ice-cream flavor among kids.: 1. You are given an input file ‘flavors.txt’. One sample example of the file is given below.2. You will design two user-defined function apart from main:3. create_flavor_dict(lines): takes the file information and creates a flavor count dictionary where key will be a ice-cream flavor and value will be the count of how many times children had that particular flavor.4. most_popular_flavor(flavor_dict): returnsthe name ofthe popular flavorfrom the flavor_dict.5. The main() function isresponsible reading from the file information and calling the two functions function.6. You MUST use a dictionary data structure to determine the count of each flavor. You then determine the most popular flavor from the dictionary values.arrow_forwardWord Puzzle GameIn this assignment is only for individual. You are going to decode the scrambled word into correct orderin this game. One round of play is as follows:1. Computer reads a text file named words.txt2. Computer randomly picks one word in the file and randomly scrambles characters in the wordmany times to hide the word3. Computer displays the scrambled word to user with indexes and gives the user options to1. Swap two letters in word based on index given2. Solve the puzzle directly3. Quit the game4. If a player chooses to swap letters, the computer reads two indexes and swaps the letters. Thegame resume to step 3 with the newly guessed word. If the resulted word after swapping is thesecret word, the game is over.5. If a user chooses to solve directly, computer prompts the user to enter the guessed word. If it’scorrect, the game is over, otherwise goes to step 3.6. After game is over, display how many times the player has tried to solve the puzzle.The following is sample…arrow_forwardPrint Person Information from file In this lab you are asked to complete the function : print_person_from_file(person_name, filename). This function should read in data from the file filename and print the information for person_name if it is found in the file. The file filename contains lines, in comma separated format (with a 'csv' extension) For each line, the items in each field are as follows: Field 1 3 4 Name Place of Birth Date of Birth Children For Children: • a person can have 0, 1 or multiple Children Multiple children are semi-colon separated If a person has no children the field contains 'NA' For example, consider the following lines froma .csv file, where Fletcher_Margaret has 3 children, and Baker_Jill has 0 children (field 4 contains the string 'NA') Fletcher Margaret,Sydney,30-09-1921,Green Bob;Green Nancy;William Tom Baker_Jill, Melbourne,08-09-1973, NA Format for Printing If the person_name is found in the file, the format for printing the person information is as…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage