ite a python program to find the longest words in a text file for example: [general-purpose, interpreted, dynamic, object-oriented, imperative] def longest_word(filename): with open(filename, 'r') as infile: words = #TO DO -- Complete the Code max_len = #TO
Q: NW Q3) IP addressing operates at the network layer (Layer 3) of OSI, IF must be able to identify ind...
A: The answer is
Q: What exactly is a design workstation? Using figures and examples, explain the subject.
A: A workstation is a high-performance computer system that is primarily intended for a single user and...
Q: You are a network manager for a large, regional Internet Service Provider (ISP) and telecommunicatio...
A: Introduction You are a network manager for a large, regional Internet Service Provider (ISP) and tel...
Q: How common is malware (which includes spyware, adware, ransomware, viruses, etc...)
A: As per company guidelines we are suppose to answer only 1 question. Kindly re-post other questions ...
Q: CUIL SavingsA gava VISual Studio Code majas O SavingsAccount.java 9+ O SavingsAccountTest.java X C> ...
A: Hopefully I have got your concern and the person suggested is correct that at end there should be br...
Q: C++ Define a problem with user input, user output, -> operator and destructors. If no output expl...
A: According to the information given:- We have to follow the instruction mentioned to perform user inp...
Q: Using Matlab, please provide the script code necessary to find the result: By simulation, generate ...
A: Code: %Generating 10000 random samples of size n=1 from an %exponential distribution with mean...
Q: What about translation and scaling? What role do these changes play in CAD software?
A: Answer:- Translation Translation changes the origin, or 0,0 point, of the canvas’s coordinate syste...
Q: What is the importance of using internet platforms for uploading and downloading?
A: Introduction: Because they support so many of our everyday activities, we have grown dependant on in...
Q: Question (5): Write an algorithm for each following problem (Ans wer Iwe only): 1. To tind sum of se...
A: Explanation Part a) I created a for loop to generate numbers from 1 to N, incremented by 2 to get...
Q: What exactly is a cyber risk assessment?
A: Let's see the solution what exactly cyber risk assessment is
Q: Assume a runner completes a 24-mile run in 1 hour, 40 minutes, and 35 seconds. Create an application...
A: Introduction Define a public class Compute. Declare variables of double datatype to hold the given v...
Q: Is there any way to use the Fitch Wood data mart for data mining? There are also some data mining to...
A: Answer: There is a vast amount of data mining that could be done using Fitch wood data mart. For exa...
Q: Explain how spatially adaptive filters (or kernels) are used for disease mapping. Explain their supe...
A: Introduction: In comparison to fixed size kernels, spatially adjustable filters have the following a...
Q: s there any relevance to clustering (k-means) with or without normalisation?
A: Introduction: The issue seeks to determine the significance of the k-means clustering algorithm. The...
Q: Is it faster or slower for user processes to communicate with shared memory? Under what circumstance...
A: Introduction: Communication between processes in shared memory occurs via shared address space. As a...
Q: What exactly is binary search? What exactly is parential dominance?
A: Binary Search a sorted list by splitting the search interval by half repeatedly. Start with the enti...
Q: Why is the top-down method preferable to the bottom-up method?
A: Introduction: The arguments for the superiority of the top-down method over the bottom-up approach a...
Q: Which of the following is not a guideline for drawing a Data Flow Diagram (DFD)? *
A: Data flow diagrams (DFD) are just the way of representation business or organization logic in the fo...
Q: asser Architecture in terms of the followings 1) Registers 2) Program Structure (Data and Code decla...
A: The answer is
Q: Given a 4-bit signed input P=P3P2P1P0 and a control input Z, use a 4-bit adder and any logic gates t...
A: 4-bit signed input P=P3P2P1P0 control input Z 4 bit added
Q: What are the treacability policies in requirement management?
A: Traceability Policies: 1. It is used to identify the specific design components which implement a gi...
Q: Make a list of the most important characteristics of DES.
A: DES: It uses the block cipher. It uses the 64 bit longer block size to complete the encryption and ...
Q: Explain how a company uses a database in its information systems, using any company as an example.
A: Introduction: Organizations use databases to make better data access within the company, stronger re...
Q: Find n the node from the end of a Linked List?
A: A linked list is a sequence of data structures, which are connected together via links. each node in...
Q: Password Spraying almost always causes account lockouts and therefore is not a popular attack tactic...
A: In Password Spraying, attackers uses brute force attack in which hackers test multiple user accounts...
Q: eate a class calculate that uses two separate functions:-a function to multiply two float numbers an...
A: Lets see the solution.
Q: la. Draw the truth table for the following set of gates with inputs A, B, C and D and result R: NOT ...
A: Gates used in given circuit: Not gate: A' : is 1 when A is 0, otherwise A is 0 Or gate: A v B : is 0...
Q: What are the different forms of data protection available in Microsoft Excel
A: Given: we have to discuss what are the different forms of data protection available in the Microso...
Q: Write Programm using oop in c++ Some form of simplified physics simulation, e.g. multiple interactio...
A: Solution: Given, Some form of simplified physics simulation, e.g. multiple interactions in an i...
Q: Write a JAVA program in which the user enters the initial velocity u, |time of travel t, and the acc...
A: Given : To write a java program to find displacement x of the object in output.
Q: Convert from Decimal to Binary Convert from binary into decimal ...
A: Decimal to binary:- Divide number by 2 and store remainder. Repeat the same step until divisor is 1...
Q: What command returns a large list of all the files in your current directory, complete with permissi...
A: Introduction: The ls command shows and provides detailed information about files and directories in ...
Q: If your computer's TCP/IP stack does not have a DNS server address and you need to access a website....
A: Basically we can access any website through either URL (DNS server) and IP addresses. DNS : The Doma...
Q: 1) C Language is available for which operating system. 2) The maximum length of a variable in c is ...
A: The answer is given in the below step
Q: Below are five labeled examples. The visual distance between points represents the distance that wou...
A: Given : 4 = positive data points 1 = negative data point.
Q: You are employed as a network administrator for a company, and your superiors have informed you that...
A: Introduction: The network of an organisation should be safeguarded against assaults in order to prev...
Q: What exactly is Intrusion Detection Software (IDS)?
A: Introduction: An intrusion detection system is a device or software application that monitors a net...
Q: When it comes to footprinting, what methods are used to do so?
A: Introduction: What approaches are used for footprinting, and what are they? Answer. Footprinting:...
Q: Describe In a computer network, penetration testing is done.
A: Penetration Testing: Penetration test is nothing but a pen test that helps in cyber-attack for the v...
Q: Computer science What is the primary goal of the disaster recovery process?
A: Introduction: Catastrophe recovery/Disaster recovery: Disasters such as fire, flooding, terrorist at...
Q: If a computer is capable only of manipulating and storing integers, what difficulties present themse...
A: The answer as given below steps:
Q: How can I make a symbol table in java? I need it to read in variable declarations? Can someone provi...
A: The full code is given below
Q: Computer science Why is scope creep so common in information system design?
A: Introduction: Information System Design will be used to finish the project. A project is a client's ...
Q: module fir ( output [7 :0] Y, input input [7:0] A, B, C, X, clk, input validsample); [7:0] X1, x2, Y...
A: Throughput: The pace at which a digital system computes outputs is known as throughput. Every two cl...
Q: Multitasking is Oa multiprogramming Ob. sequential Oc. concurrent Od timeshare O e. parallel
A: Multi tasking:
Q: List two advantages and two disadvantages of having international standards for network protocols.
A: answer is
Q: Computer science What raid level distributes data across numerous discs for better performance and ...
A: Introduction: What raid level distributes data across numerous discs for better performance and faul...
Q: You have to create a memory size calculator in the C language that inputs the number of elements and...
A: The question is to write C code for the given problem.
Q: What is a just-in-time (JIT) compiler, and how does it work? So what are the possible benefits of th...
A: Answer the above questions are as follows:
Write a python program to find the longest words in a text file
for example: [general-purpose, interpreted, dynamic, object-oriented, imperative]
def longest_word(filename):
with open(filename, 'r') as infile:
words = #TO DO -- Complete the Code
max_len = #TO DO -- Complete the Code
words = infile.read().split()
print(longest_word('test.txt'))
Step by step
Solved in 2 steps with 1 images
- Write a python program that uses a dictionary to assign “codes” to each letter of the alphabet. For example: codes = { ‘A’ : ‘%’, ‘a’ : ‘9’, ‘B’ : ‘@’, ‘b’ : ‘#’, etc . . .} Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol @, and so forth. The program should open a specified text file (text.txt), read its contents, then use the dictionary to write an encrypted version of the file’s contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file. Write a second program that opens an encrypted file and displays its decrypted contents on the screen. Below is the required dictionary. ➔➔➔➔➔➔➔➔ # Encryption and decryption are inverse of one another CODE =…An “inverted file” is a critical data structure for implementing applications like the index of a book, or a web search engine. Given a document D (which can be viewed as an unordered, numbered list of words), an inverted file is an ordered list of words L such that for each word W in L, we store the indices of the places in D where W appears. Write a C# program (from scratch please, written by yourself (ask instructor if you are stuck), not borrowed from any other sources) that reads in a list of words separated by spaces from a text file, then uses an efficient O(N) algorithm to create the inverted file index (hint: consider the topic of this chapter, consider using a Dictionary/hashtable to help you), and writes this index out to another file or prints it to the screen. Each line of the output file should start with the next word (the words should be listed in alphabetical order, and this sorting does not have to be part of the O(N) runtime complexity, e.g. you can use regular…make a script explaining the python code line by line class Course: course_count = 0 def __init__(self, id_num, units, title): self.id_num = id_num self.units = units self.title = title Course.course_count += 1 def __str__(self): return f"ID: {self.id_num}, Title: {self.title}, Units: {self.units}" class CourseManager: def __init__(self): self.courses = [] def add_course(self, id_num, units, title): self.courses.append(Course(id_num, units, title)) def list_all_courses(self): if not self.courses: print("Your list is empty.") else: print("Your course list:\n") print("Course\t Unit\t Title") for course in self.courses: print(course.id_num," ",course.units,"\t ",course.title) def search_by_word(self, word): word = word.lower() result = [] for course in self.courses: if word…
- write program code in java: Write a program that reads two files “Data1.txt”, “Data2.txt”; Then add their corresponding elements and produce an output file “output.txt”. If the number of elements are not equal, fill the elements of the smaller file up with “0” s. Sample output: Elements of the “Data1.txt”: 3 5 7 8 9 Elements of the “Data2.txt”: 45 11 Elements of the “Output.txt”: 48 16 7 8Rewrite the program in Example 3-1. DigestThread class to output the result of each file on an output file for each one by assigning a new name for the output file. The language is Java Example 3-1. DigestThread import java.io.*; import java.security.*; import javax.xml.bind.*; // for DatatypeConverter; requires Java 6 or JAXB 1.0 public class DigestThread extends Thread { private String filename; public DigestThread(String filename) { this.filename = filename; } @Override public void run() { 56 | Chapter 3: Threads www.it-ebooks.info try { FileInputStream in = new FileInputStream(filename); MessageDigest sha = MessageDigest.getInstance("SHA-256"); DigestInputStream din = new DigestInputStream(in, sha); while (din.read() != -1) ; din.close(); byte[] digest = sha.digest(); StringBuilder result = new StringBuilder(filename); result.append(": "); result.append(DatatypeConverter.printHexBinary(digest)); System.out.println(result); } catch (IOException ex) {…Write a java program that will generate a permuterm index from the terms in the files in an input directory. The program should prompt the user for a single directory and find all of the terms (after processing) in each file in it. The program should then find the permutations of each term and store them (keeping track of the original word each permutation comes from). After all of the text files in the directory have been read, the output of the program should display the permutations in sorted order along with the original term. Use the dollar sign as the end of term symbol.
- Computer Science Consider the following C program that manipulates newly created file named foo.txt. Write the contents of foo.txt after its execution. int main(int argc, char *argv[]) { close(STDOUT_FILENO); int f = open(“foo.txt”, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU); assert (f >= 0); int rt = fork(); if (rt == 0) { write(f, “Child here!\n”, 20); printf(“Child terminates.\n”); } else if ( rt > 0) { (void) wait(NULL); write(f, “Parent here!\n”, 21); printf(“Parent terminates.\n”); } return 0; }Write a python program that scans in a large number of tweets from a file, and prints the top 5 hashtags. Approach Parse each word in the file Find a way to isolate the hashtags from the rest of the tweet Compute the frequency of each unique hashtag. Find the top 5 hashtags. Caveats 1. Because this is public dataset, there are many tweets that use special characters that may cause issues during reading in your file. To avoid this, explicitly specify the encoding mode in open when reading in the file. with open('twitter_data.txt', 'r', encoding='utf8') as f: 2. When parsing hashtags be sure to change everything to lowercase. There are cases in the file where two hashtags are the same but differ in case. 3. There is no standard way of sorting a dictionary based on the values. Python gives you access to a sorted function where you can pass in a collection and also specify a comparator which outlines how you want to sort the values. This can be done with a one line lambda function.You are a cyber investigator, your task is to write a python program that can read file signatures from a file and save them into a list. Each file signature is an element of your list. Then, try to find out if there is a JPG file in there. If there is a JPG file, print out a True on screen. (File Signature for JPG file is: FF D8 FF DB) The input file is: FSCS360_Midterm_Exam_Part2.txt
- Write a Java program that reads from a URL and searches for a given word in the URL and creates a statistic file as an output. The statistic file needs to include some information from the URL. URL address Number of words in the URL page Number of repetitions for a given word displays the number of times the word appears. You need to have two functions, one for reading from the URL and the other function for searching the word.Write a python 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…Write a program that reads a text file and creates an alphabetical index of words and in which lines of this original example. The file name is given as an argument to main (). Ignore the small-capital (all lowercase: k,l,p) and punctuation. Solve with ternary tree using the TST.java class (https://algs4.cs.princeton.edu/52trie/TST.java.html). An execution snapshot is then given. For the file: It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness It will appear Index of file: exercise.txt age 3-4 best 1 foolishness 4 it 1-2-3-4 of 1-2-3-4 the 1-2-3-4 times 1-2 was 1-2-3-4 wisdom 3 worst 2