3. Write a Python function that implements interpolation search. The function takes two parameters – a file name and the value it is searching for. Your function should read in this file and similarly formatted files. Assume that the input file, such as data.txt, is sorted. Your code should return two values: (1) the number of comparisons performed to find/not find the value and (2) the index position of the value (or -1 if it is not found). Please comment on code so I can
Q: Write a program to calculate the net pay of an employee. Input the basic pay, pass basic pay to user…
A: #include<iostream.h>#include<conio.h> class Employee{ char emp_name[30]; int…
Q: Write a function that takes two lists of integers X and Y as input, and computes and writes a table…
A: def op2file(X, Y): f = open("question2.txt", mode='x') for x in X: for y in Y:…
Q: This lab will explore how to define a new C++ data type and also how to combine multiple C++ files…
A: Source Code: 1. printMeFirst.h For copy #include<iostream>using namespace std; void…
Q: 3. an output file and reduces the input file by that factor in each dimension. For example, if the…
A: given - C Program Task Write a programme called pgmReduce which takes 3 arguments:1. an input file…
Q: Write a cpp file and Pass two one dimensional array as an arguments to a function and compare the…
A: Code : // C++ program to find given two array// are equal or not#include <bits/stdc++.h>using…
Q: 7- There are important differences between values that are printed and output values. Consider the…
A: Task : In the given question , the code for the three functions is given below. The task is to find…
Q: Implement a function writeEmpToFile that takes two arguments: a struct Employee pointer and a FILE…
A: Answer is given below. Read carefully. Thank you......
Q: Implement a function writeEmpToFile that takes two arguments: a struct Employee pointer and a FILE…
A: The Answer is
Q: Mrite a function that takes two lists of integers x and Y as input, and computes and writes a table…
A: def op2file(X, Y): f = open("C:\\Users\\Dell\\OneDrive\\Desktop\\question2.txt", "w") for i in…
Q: Write a recursive function, displayFiles , that expects a pathname as an argument. The path name can…
A: Here I written Python code as per problem says. I hope you like it.
Q: Write a function that takes two lists of integers X and Y as input, and computes and writes a table…
A: def writefile(X, Y): f = open("question2.txt", mode='x') for x in X: for y in Y:…
Q: Write a C function with the following prototype: int copyFile(char *filenamel, char *filename2);…
A: #include <stdio.h>#include <stdlib.h> int copyFile(char *filename1,char *filename2){…
Q: Write a function IN C LANGUAGE that splits the following data read from a file named info.txt and…
A: A file is defined using a stream. The stream is declared using FILE *. The open() function opens a…
Q: Write a function that takes two lists of integers X and Y as input, and computes and writes a table…
A: Solution logic Given function which will write in a txt file name ques2 def 2 variables x and y…
Q: Write a C++ function with the following signature: int sumArray(int arr[], int n) that returns the…
A: Here is the c++ code:
Q: Create a new file in c++ and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create…
A: Program Instructions:In the header file, create a temporary variable temp of the data type of each…
Q: Write a Python function that implements binary search. The function takes two parameters – a file…
A: def binary_Search(file, value): #function takes filename and value f = open(file, 'r') #open…
Q: Write a Python function that implements binary search. The function takes two parameters – a file…
A: The function binary_search() will take two parameters- a filename and the value that has to be…
Q: Write a program that creates a function to read multiple DNA sequences from the user and writes them…
A: Code: # Python program to convert# altered DNA to protein inputfile ="DNA_sequence_original.txt" f…
Q: Let A and B two text files, containing some binary lines between of length 1...N. Where N is the…
A: Python code to compare binary value stored in two different text files
Q: Write a Python function that implements sequential search. The function takes two parameters - a…
A: def linear_Search(file, value): #function takes filename and searching value f = open(file, 'r')…
Q: Write a function that takes two lists of integers X and Y as input, and computes and writes a table…
A: Given: python dont use input,print use return
Q: 2. Using the algorithm developed above, create a function that determines the status of the first…
A: Create a text file. file.txt contains:
Q: Complete the below function that takes a file name and a list as arguments and reads the text within…
A: For this program first, we created an empty dictionary in which key is representing a character in a…
Q: PROGRAM IN PLAIN C PLEASE! Write a void function that will merge the contents of two text files…
A: Solved BY C programming
Q: This lab will explore how to define a new C++ data type and also how to combine multiple C++ files…
A: Actually, program is an executable software that runs on a computer.
Q: Question: Write a program, maxmin.c, which uses two functions readvalues() and range() to find the…
A: Use file stream to load the data and read to arrays and then use another stream to write contents to…
Q: Write a function stat(fName) that takes a filename that contains a matrix of numbers. Your function…
A: Algorithm: Start Open the file in read mode and read the content and store it in a variable By…
Q: Write a function report(filename) that consumes a string file and returns the grades of each student…
A: class Coursegrade: ''' Fields: grade(Str) course(Str) Requires: grade in ['4', '5', '6', '7',…
Q: The file text.txt contains a sentence text written in all small letters and does not have any…
A: import java.io.*; import java.util.*; // We have a class named Main public class Main { // We…
Q: Write a function reverse_file(f) that takes a file name f. After your function runs, the lines in f…
A: file can be opened by specifying the file location and mode of operation
Q: This lab will explore how to define a new C++ data type and also how to combine multiple C++ files…
A: Actually, program is an executable software that runs on a computer.
Q: 2. Using the algorithm developed above, create a function that determines the status of the first…
A: The function status of return type void and four parameters can be defined to find the status of…
Q: Write a C function willH dle int copyFile (char filenamel, char filename2); Siven the names of a…
A: The function reads characters from the source file and copies into the destination file. If the…
Q: quenton Consider the following piece of code that opens a file with file pointer fp, in this file…
A: Here fp is the file pointer and the name and surname are string variables which do not require &…
Q: Write a C++ function that meets the following specification. Name: wordFinder Inputs: 1) input…
A: NOTE: - Since the file is not given, hence a sample file is taken to implement the required C++…
Q: Write a Python program that calculates the average 5 quiz scores fr Your program must have 2…
A: Note: Both txt files and .py files should be saved in Desktop. i consider only 5 quizes but the…
Q: Write a function that takes two lists of integers X and Y as input, and computes and writes a table…
A: A list is a type of collection in Python. A list may be considered as an array and accessed using an…
Q: Write a program that creates a function to read multiple DNA sequences from the user and writes them…
A: Python: def convertFileToSequence(filename): clean = -1 # used for determining output # read in file…
Q: Write a function IN C LANGUAGE that splits the following data read from a file named info.txt and…
A: For writing in file, it is easy to write string or int to file using fprintf and putc, but you might…
Q: using CSV write a function that takes a list of strings as inputs, and returns a single string…
A: We will join the passed strings using join() function. Below is the function which will join the…
Q: Need help in creating a C(NOT C+ OR C#) FUNCTION that will help split a string present in a Text…
A: Use of strtok () The strtok() function reads string1 as a series of zero or more tokens,…
Q: Write a program to calculate the net pay of an employee. Input the basic pay, pass basic pay to…
A: Since programming language not mentioned, using C++ CODE: #include <iostream>using…
Q: k: Write a program in C++ language, using functions only, with the following features. Program…
A: Actually, c++ is a powerful general purpose language. The, code has given below:
Q: Complete the below function that takes a file name and a list as arguments and reads the text within…
A: For most of the understanding, I have added the comments in the code To run the code just enter the…
Q: Write a C++ program to create a new file named “college.txt” to store list of colleges under Punjab…
A: Required: Write a C++ program to create a new file named “college.txt” to store list of colleges…
Q: 11. Write a Python function called word_count that takes a file name as an argument. The function…
A:
Q: make_dictionary Creates a dictionary from a file's contents. Each line in the file is split into a…
A: Use try-except block to handle if any Exception occurred while opening file
Thank you, make up a file if need be of sorted data
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 1. Consider the following incomplete C++ program: #include int main() { … } a. Write a statement that includes the header files fstream, string, and iomanip in this program. b. Write statements that declare inFile to be an ifstream variable and outFile to be an ofstream variable. c. The program will read data from the file inData.txt and write output to the file outData.txt. Write statements to open both of these files, associate inFile with inData.txt, and associate outFile with outData.txt. d. Suppose that the file inData.txt contains the following data: Giselle Robinson Accounting 5600 5 30 450 9 75 1.5 The first line contains a person's first name, last name, and the department the person works in. In the second line, the first number represents the monthly gross salary, the bonus (as a percent), and the taxes (as a percent). The third line contains the distance traveled and the traveling time. The fourth line contains the number of coffee cups sold and the cost of each coffee cup. Write statements so that after the program executes, the contents of the file outData.txt are as shown below. If necessary, declare additional variables. Your statements should be general enough so that if the content of the input file changes and the program is run again (without editing and recompiling), it outputs the appropriate results. Name: Giselle Robinson, Department: Accounting Monthly Gross Salary: $5600.00, Monthly Bonus: 5.00, Taxes: 30.000 Paycheck: $4116.00 Distance Traveled 450.00 miles, Traveling Time: 9.00 hours Average Speed: 50.00 miles per hour Number of coffee Cups Sold: 75, Cost: $1.50 per cup Sales Amount = $112.50 e. Write statements that close the input and output files. f. Write a C++ program that tests the statements in parts a through e.In c++ creates a function checkWord that:1) uses an input file stream to read input file (file1) containing correctwords from the English dictionary into a proper STL container.2) uses an input file stream to read another input file (file2) containinguntrusted English.3) Words that we need to check its correctness against the trusted filefrom the dictionary.4) Prints the incorrect words in file2 after checking it against file1.5) If there are no incorrect words, the function should print “All wordsare correct”.Write a function that takes two lists of integers X and Y as input, and computes and writes a table into a file named "question2.txt" as follows: - On each line the computations for an X,Y pair is given Each such possible pair must exist in the file in the same order of values in X and Y Next on each line, you provide X+Y, X*Y and X^2 + Y^2, all separated by a comma (and no spaces or other characters must exist). Note that X^2 represents "square of X". For example, given X = [1,3] and Y=[-1,1,0], "question2.txt" should contain the following table: question2.txt 1,-1,0,-1,2 1,1,2,1,2 1,0,1,0,1 3,-1,2,-3,10 3,1,4,3,10 3,0,3,0,9 As you can see, the first line is computed for X=1, Y=-1. The second line is built for X=1, Y=1; and the third line is for X=1, Y=0. It goes on like this, until X=3, Y=0. def op2file(X, Y): in python
- PROGRAM IN PLAIN C PLEASE! Write a void function that will merge the contents of two text files containing chemical elements sorted by atomic number and will produce a sorted file of binary records. The function’s parameters will be three file pointers. Each text file line will contain an integer atomic number followed by the element name, chemical symbol, and atomic weight. Here are two sample lines: 11 Sodium Na 22.99 20 Calcium Ca 40.08 The function can assume that one file does not have two copies of the same element and that the binary output file should have this same property. Hint: When one of the input files is exhausted, do not forget to copy the remaining elements of the other input file to the result file.This problem needs to be solved in python. Write a function read_movies_data(f) that takes in a movies file and returns a pandas DataFrame, where the index is the movie id and the columns are "title", "year", and "genre" (in that order). movies_df = read_movies_data("moviesSample.txt") assert movies_df.shape == (9, 3)assert movies_df.iloc[2, 2] == "Comedy"assert movies_df.loc[6, "title"] == "Heat"assert all(movies_df.columns == ["title", "year", "genre"])assert list(movies_df.index) == [1, 2, 3, 4, 5, 6, 8, 9, 10] NOTE: Make sure all of the asserts work The moviesSample.txt looks like this: 1|Toy Story|1995|Adventure2|Jumanji|1995|Adventure8|Tom and Huck|1995|Adventure3|Grumpier Old Men|1995|Comedy4|Waiting to Exhale|1995|Comedy5|Father of the Bride Part II|1995|Comedy6|Heat|1995|Action9|Sudden Death|1995|Action10|GoldenEye|1995|Action NOTE: Try to sent screenshots of the code working.Write a function that takes two lists of integers X and Y as input, and computes and writes a table into a file named "question2.txt" as follows: - On each line the computations for an X,Y pair is given - Each such possible pair must exist in the file in the same order of values in X and Y- Next on each line, you provide X+Y, X*Y and X^2 + Y^2, all separated by a comma (and no spaces or other characters must exist). Note that X^2 represents "square of X". For example, given X = [1,3] and Y=[-1,1,0], "question2.txt" should contain the following table: ----- question2.txt -----1,-1,0,-1,21,1,2,1,21,0,1,0,13,-1,2,-3,103,1,4,3,103,0,3,0,9------------------------- As you can see, the first line is computed for X=1, Y=-1. The second line is built for X=1, Y=1; and the third line is for X=1, Y=0. It goes on like this, until X=3, Y=0.
- 1. Given two .txt files that have lists of numbers in them, find the numbers that areoverlapping (print them in the output). “primenumbers.txt” has a list of all primenumbers under 1000, and the other “happynumbers.txt” has a list of happy numbersup to 1000.We can divide this problem into different parts:a. Write a function (call it readFile) that takes the name of a file as argument and read the content of the file and store it in a list (each line contains onenumber, so each number is stored in the list) and return the list.b. Write a function that takes two lists and return another list containing thecommon elements of two lists (you have written this function before! You canuse it)c. Write a function (call it writeFile) that takes a list and name of a file. The function should write the content of the list in the file (each element in oneline).d. Use the above functions to do the task of this lab.The following Python code is a partially written function that attempts to read a file's contents into a dictionary. Fill in the missing code in the make_dictionary function. You do not need to copy any of the existing code. Just write the code that would go in place of "YOUR CODE HERE". def make_dictionary(filename):'''Function -- make_dictionaryCreates a dictionary from a file's contents. Each line in the file is split into a list at commas.If, after splitting, the list contains exactly 2 parts,the first item is added to the dictionary as a keyand the second item is the value. If the providedfile doesn't exist, the message "File doesn'texist" is printed to the terminal and anempty dictionary is returned.Parameter:filename -- The name of the file to open.Returns:A dictionary of the file's contents, if thefile matches the expected format. Otherwise, anempty dictionary is returned.'''contents = {}# YOUR CODE HEREreturn contents Example If the contents of the file passed to the function…Write a cpp program that contains class “candidate”. A candidate has a name, number of electoral votes and number of popular votes.In your program, write a function that reads an input file containing elections results using input file stream and output to the console the name of the winner, his electoral votes and his popular votes.Your function should be prominent to faulty data; for example, if the number of votes for one of the candidates was a negative number, the function should exit and print a proper error message on the screen (You must use exceptions to do this)
- Write a C program that, 1. writes an n x n matrix into a file named "matrix.txt" the matrix has to contain the number as it is given in the example, and n has to be given by the user 2. contains a function with the name "averageM", which o input parameters are the main diagonal (in the example: [0,1,3]) o of the matrix and the size of the main diagonal (in the example: 3) o and returns with the average of the numbers in the main diagonal (in the example: 1.33) 1. calls the "averageM" function on the matrix.txt" and displays the result on the screen Instruction for the user: "n=": Example: Input: 3 Output in the file: 001 112 223 Output on the screen: 1.33Please I want a python program for this using CSV write a function that takes a list of strings as inputs, and returns a single string created by joining all the input strings together, with a comma separating them. Now write another function that takes a list of lists of strings, applies the operation from question 1 to each list, and writes the result as a row of an output file. The function should return the path to the file where the strings were written. 3. Now, write the reverse of question 2: write a function that takes in a filename (which we will assume is a CSV), and returns a list of lists of strings, where one row in the file corresponds to one list in the output list (and each value between the commas in the file row is one element in the list).Implement a function writeEmpToFile that takes two arguments: a struct Employee pointer and a FILE *. It should write each field in order as an appropriate type. Note that you will probably want to write a length of the name before you write the characters of the name. By doing this, when you write the load function below, you can read the length of the string and use it to malloc a buffer of the proper size to hold the name. Because of the embedded name pointer, you CAN NOT write the Employee struct as a single struct. You will need to write it out field by field. You will want to write this as a binary file, not as a text file. Implement a SAVE command in your main loop that will save all the employees out to a file. The SAVE command should ask for a file name, similar to the way your FIND command asked for a name. Below is the work I have done so far that is required from the image but I have not been able to finish it and I need assistance with making the final changes that…