Assignment 3 Exercise: Suppose you are given a text file "students.txt" that contains the data of students. Every line in the file is composed by the first name, the last name, the score of the test1, the score of the test2 and the grade of the final. Write a program that: a. Read the file "student.txt" b. Create a new file named "Result.txt". Write in this file the list of the admitted students (total score >= 60). Each line should contain, the first Name, Last Name, the total score and the string "PASS". The total score is calculated as the following: total= Test1*0.2+Test2*0.2+Final*0.6
Q: Write a program that removes all the occurrences of a specified string from a text file.
A: program that removes all the occurrences of a specified string from a text file.
Q: Question 3 (File Handling) Assume you have the following text file (marks.txt) and storing a set of…
A: The answer for the above question is given in the following steps.
Q: (Occurrences of each letter) Write a program that prompts the user to enter a file name and displays…
A: Please give positive ratings for my efforts. Thanks. PROGRAM import java.io.*; import…
Q: #7 - program that readsthe file named randomPeople.txt sort all the names alphabetically by last…
A: The code for the program is given below
Q: 7.8 LAB: Word frequencies (lists) Write a program that first reads in the name of an input file and…
A: I have provided CSV FILE SCREENSHOT , PYTHON CODE , CODE SCREENSHOT and OUTPUT…
Q: my_list.txt: 150+250 Which of the following code blocks writes the sum (400) in a new line of the…
A: General information for the code structure, first line reads the file in read, write and update…
Q: Exercise 3: Write a program that reads from an input file "scores.txt" student test scores in he…
A: The split function in python language : The split function takes a delimiter as input and splits the…
Q: Write a program that does the following: Reads information from a text file into a list of…
A: Actually, the code has given below:
Q: 9.11 LAB: Course Grade Write a program that reads the student information from a tab separated…
A: ANSWER:-
Q: (Late Assignments will not be accepted for any reason) Counting the character occurrences in a file…
A: PROGRAM CODE: #include <stdio.h> #include <stdlib.h> //Function to print histogram…
Q: PLEASE ONLY GIVE ANSWER IN PYTHON!! In PYTHON: Given a set of text files containing synonyms for…
A: Step 1: Initialize a dictionary syn. Step 2: Prompt and accept the word and starting letter from the…
Q: A photographer is organizing a photo collection about the national parks in the US and would like to…
A: To write a program in java for replacing the _photo.jpg with _info.txt in the file names mentioned…
Q: Blood sugar is considered normal if its rate is Ines than 140 and greater than 70 , it is considered…
A: Given: Blood sugar is considered normal if its rate is Ines than 140 and greater than 70 , it is…
Q: Exercise #3: Write a program that finds all students who score the highest and lowest average marks…
A: //hw2.java import java.io.File;import java.io.FileNotFoundException;import java.io.FileWriter;import…
Q: num.txt is a file that contains a list of scores. num.txt 10 25 36 45 89 42 54 create a program that…
A: Solution- Programming language - Python All necessary comments are included in program code.…
Q: step 1: Write a program that will ask the user for their grocery list, one item at a time, and will…
A: NOTE : As the question is not specific about the programming language to be used , so python has…
Q: Write a program that reads the student information from a tab separated values (tsv) file. The…
A: CODE 1: try: # opening file for reading fileread= open("StudentInfo.tsv") # opening file for…
Q: Problem 1. Character Analysis-Use the file text.txt that is attached. Write a program that reads the…
A: The python built-in open() function can open a file in reading mode. The read() function will read…
Q: (Baby name popularity ranking) The popularity ranking of baby names from the years 1960s to 2010 are…
A: Required:
Q: Exercise 2: File manipulation Assume that we have a first file called French.txt enclosing the…
A: C++ program to display the translated French words and their equivalent words. Create a file named…
Q: Exercise: Suppose you are given a text file "students.txt" that contains the data of students. Every…
A: The program is to : 1. read from the "students.txt" file containing the student details. 2.…
Q: 6. File Analysis Write a program that reads the contents of two text files and compares them in the…
A: Note : Answering in python as no programming language is mentioned. Task : Read two text files.…
Q: Q3. There are two existing data files: "rawdata.txt and 'marks.txt. The file 'rawdata.txt is used to…
A: C++ program is given below
Q: "### Exercise 2 Working with a file and numbers ###\n", "\n", "The file grades.txt has the grade for…
A: Task : Read the grades from grades.txt. Find the average grade. Show the average grade of the…
Q: 12.7: Sentence Filter C++Write a program that asks the user for two file names. The first file will…
A: A C++ program for the given criteria is as follows, File name: “main.cpp” /* C++ Program to convert…
Q: Exercise 2 Write a Program that reads integers from a file called "input.dat" (Figure 1) that…
A: Provided the Python program with appropriate comments and as per requirements given in above…
Q: • Exercise # 1 Write a program that reads a file containing text. Read each line and send it to the…
A: In step 2, you will get python code. In step 3, you can see the sample output.
Q: Exercise 3: Write a program that reads from an input file "scores.txt" student test scores in the…
A: Given: Python program that reads from an input file “scores.txt” student test scores inthe range 0 –…
Q: Write a write_scores function that opens the file, and writes scores and names from lst_scores and…
A: def write_scores(file_name, lst_score, lst_names): with open(file_name, 'w') as f: for i…
Q: Task 2 Write a python program to find the longest word in a file. Then print the word. Input: [in a…
A: Python program to find the longest word in the given text file.
Q: Write a short notes on the following appending to a file deleting a file
A: a short notes on the following appending to a file deleting a file
Q: A photographer is organizing a photo collection about the national parks in the US and would like to…
A: Ans:) NOTE: I am solving this problem in python as no programming language is mentioned. Approach:…
Q: Write a program that first reads in the name of an input file, followed by two strings representing…
A: Write a program that first reads in the name of an input file, followed by two strings representing…
Q: "### Exercise 2 Working with a file and numbers ###\n", "\n", "The file grades.txt has the grade for…
A: The required python program code by using the file operation is given in the next step.
Q: Exercise 6. Create a dictionary from a Text File: When a program incorporates a large dictionary,…
A: Answer: For python, I have used Dictionary which is created from a file, Here I have used a Text…
Q: 8) Write a program that finds pairs of numbers between 1 and 49 that have no common divisor other…
A: As no programming language is mentioned, it is solved using basic C++
Q: Complete the lines program which opens the files specified on the command line and prints the name…
A: #include<iostream> #include<fstream> using namespace std; int main(int argc, char*…
Q: Exercise 1: Write a Python program that reads from the user the name of two files (an input file and…
A:
Q: Exercise 1: Write a Python program that reads from the user the name of two files (an input file and…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Problem A straight line can be defined by a pair of points pi(x1, yı) and p2(x2, y2). The slope m of…
A: code: from math import inf def getCoordinates(s):#strip and split the line to get the…
Q: Assume that you have two files given : answer.txt and key.txt files. answer.txt file includes…
A: Programming instructions: Include necessary header files. Declare required variales. Open the…
Q: Code should be in Python Write a program that first reads in the name of an input file, followed by…
A: print("Input")filename = input()lower = input()upper = input() fin = open('input1.txt', 'r')Lines =…
Q: The course records are shown below: Each student has 4 assignments. 108194 9…
A: C++ Code: #include <iostream>#include <fstream>#include <cstdlib>#include…
Q: Write a program that asks for user's name, phone number and address. The program then saves all…
A: Step 1 : include fstream and string file and iostream file Step 2 : create 3 variables of string…
Q: 4. Warning Write a program that will read in a file of student academic credit data and create a…
A: java code is given in below:
Q: 11.11 LAB: Course Grade Write a program that reads the student information from a tab separated…
A: According to the information given:- We have to make grade report card. for student.
Q: (PYTHON) A photographer is organizing a photo collection about the national parks in the US and…
A: Procedure- for this python provide open() method to open a file. then we remove the unwanted space…
Q: A photographer is organizing a photo collection about the national parks in the US and would like to…
A: The Answer start from step-2.
Q: Suppose you are given a text file "students.txt" that contains the data of students. Every line in…
A: Notes: 1) There were no restriction stated hence I have made this way. 2) There were no mentioned of…
Q: In a text file, I have two numbers each line. The numbers are the employee ID and the number of…
A: the solution is given in next step
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
- Implement function duplicate() that takes as input a string and the name of a file in the current directory and returns True if the file contains duplicate words and False otherwise. Hints: remember to save the function and the text file in the same directory. def duplicate(filename): 'Put in docstring’ # get file content infile = ________________# ______________ content = ______________# ______________ infile__________________# ______________ # replace punctuation with blank spaces and obtain list of words table = ________________________ # _______________ words = _______________________ # _______________ # for every word, check if it occurs more than once; if so, return True for word in words: if ______________________ # _____________ _________________# _____________ # no word occurred more than once, so return False ______________ Result of running the function. >>> duplicate('Duplicates.txt') True >>> duplicate('NoDuplicate.txt') FalseWrite a program that does the following: Reads information from a text file into a list of sublists. Be sure to ask the user to enter the file name and end the program if the file doesn’t exist. Text file format will be as shown, where each item is separated by a comma and a space:ID, firstName, lastName, birthDate, hireDate, salary Store the information into a list of sublists called empRoster. EmpRoster will be a list of sublists, where each sublist contains the information for one employee.The birthDate and hireDate in file are strings, but should be stored as objects of type Date.Example of EmpRoster list with 2 employees:[ [111,”Joe”, “Jones”, “09-01-1980”,”10-19-1999”, 95000], \ [222, “Sam”, “Smith”, “07-10-1956”,, “01-01-2000”, 50000] ] Print a report that shows the following: Employee RosterID First Name Last Name Birth Date Age Hire Date YrsWorked Salary WRITE the following information out to a text file…my_list.txt: 150+250 Which of the following code blocks writes the sum (400) in a new line of the file? a. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + i file.write(str(sum)) b. with open('my_list.txt', 'r+') as file: line = file.readline() for i in line.split('+'): sum = sum + int(i) file.write(str(sum)) c. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split(): sum = sum + int(i) file.write(str(sum)) d. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + int(i) file.write(str(sum))
- Exercise 6. Create a dictionary from a Text File: When a program incorporates a large dictionary, the dictionary is usually created from a file, such as a text file by using dict function to convert a list into a dictionary. Whenever a word in the original sentence is not a key in the dictionary, the get method places the word itself into the translated sentence. The file “Textese.txt” contains a word and its translation into textese. Write a program to create a dictionary with the file, ask the user to enter a simple sentence then translate it into textese. Define two function createDictionary (filename) and translate (sentence, dictionary). Then define a main function to test your functionspython my_list.txt: 150+250 Which code block writes the sum in a new line of the file? a. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split(): sum = sum + int(i) file.write(str(sum)) b. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + i file.write(str(sum)) c. with open('my_list.txt', 'r+') as file: line = file.readline() for i in line.split('+'): sum = sum + int(i) file.write(str(sum)) d. with open('my_list.txt', 'r+') as file: line = file.readline() sum = 0 for i in line.split('+'): sum = sum + int(i) file.write(str(sum))Code should be in Python Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds of a search range. The file should be read using the file.readlines() method. The input file contains a list of alphabetical, ten-letter strings, each on a separate line. Your program should output all strings from the list that are within that range (inclusive of the bounds). Ex: If the input is: input1.txt ammoniated millennium and the contents of input1.txt are: aspiration classified federation graduation millennium philosophy quadratics transcript wilderness zoologists the output is: aspiration classified federation graduation millennium Notes: There is a newline at the end of the output.
- step 1: Write a program that will ask the user for their grocery list, one item at a time, and will write it to a file called groceries.txt. The program should create a new file called groceries.txt that will contain all of the user’s groceries when opened. Step 2: Modify the program that creates a groceries.txt file so that if the user’s favourite fruit is not on the list, the program will append it to the end of groceries.txt file.C++ Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. Assume also the last names and first names do not contain whitespaces. 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 grades of the…Chapter 4. PC #6. File Letter Counter (page 264) Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop. Here is a working code Please modify it so it passes the test cases because I run it it does not work: mport java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class FileRead {public static void main(String[] args)…
- Chapter 4. PC #6. File Letter Counter (page 264) Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop. Here is a working code Please modify it so it passes the test cases because I run it it does not work: Also I do not need Goodbye And I run it through hypergrade which it has all the test cases it does not work. mport java.io.File;import…Chapter 4. PC #6. File Letter Counter (page 264) Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop.Chapter 4. PC #6. File Letter Counter (page 264) Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop. Test Case 1 Please enter the file name or type QUIT to exit:\nQUITENTER Test Case 2 Please enter the file name or type QUIT to exit:\nbadfilename.txtENTERFile: badfilename.txt does not exist.\nPlease enter the file name again or…