Python program
You are given the following text file called Mytext.txt. Write a Python function called search_file that accepts the name of the file (i.e. filename) and a string to look for in the file (i.e. mystring) as parameters. The function then looks for mystring in the file. Whenever it finds the string in a line, it saves the line number and the text for that line in a dictionary. Finally, it returns the dictionary after reading all the lines in the file and populating the dictionary with all matching line numbers and line text. If an empty string or a blank string is passed as mystring then an empty dictionary is returned.
Sample Input: search_file("Mytext.txt","python")
Sample Input: search_file("Mytext.txt","")
Contents of Mytext.txt
Python is an interpreted, high-level, programming language.
Python is dynamically typed and garbage-collected.
Python was conceived in the late 1980s.
Python 2.0, was released in 2000.
Python 3.0, was released in 2008.
The interpreters are available for many operating systems.

Answers

Answer 1

Answer:

The function in Python is as follows:

def search_file(filename,mystring):

my_dict = {}

count = 0

file = open(filename)

lines = file.readlines()

for line in lines:

 count+=1

 if mystring.lower() in line.lower():

  my_dict[count] = line.rstrip('\n')

return my_dict

Explanation:

This defines the function

def search_file(filename,mystring):

This initializes an empty dictionary

my_dict = {}

This initializes the number of lines to 0

count = 0

This opens the file

file = open(filename)

This reads the lines of the file

lines = file.readlines()

This iterates through the lines

for line in lines:

This increments the number line

 count+=1

This checks if the string exists in the line

 if mystring.lower() in line.lower():

If yes, the line number and the string are added to the dictionary

  my_dict[count] = line.rstrip('\n')

This returns the dictionary

return my_dict


Related Questions

Given that
f(x) = 5x +3.
Find f (4)​

Answers

Answer:

Given that

f(x) = 5x +3.

f (4)=5×4+3=23

Explanation:

hope it's helps you have a good day☺

Describe a cellular network, its principal components, and how it works.

Answers

Answer:

The final basic component of a cellular system is the Gateway. The gateway is the communication links between two wireless systems or between wireless and wired systems. There are two logical components inside the Gateway: mobile switching center (MSC) and interworking function (IWF).

Explanation:

Using recursion, write a program that asks a user to enter the starting coordinates (row, then column), the ending coordinates (row then column), and calculates the number of paths from the starting coordinate to the ending coordinate.

Answers

Answer:

The program in Python is as follows

def Paths(row,col):

if row ==0 or col==0:

 return 1

return (Paths(row-1, col) + Paths(row, col-1))

row = int(input("Row: "))

col = int(input("Column: "))

print("Paths: ", Paths(row,col))

Explanation:

This defines the function

def Paths(row,col):

If row or column is 0, the function returns 1

if row ==0 or col==0:

 return 1

This calls the function recursively, as long as row and col are greater than 1

return (Paths(row-1, col) + Paths(row, col-1))

The main begins here

This prompts the user for rows

row = int(input("Row: "))

This prompts the user for columns

col = int(input("Column: "))

This calls the Paths function and prints the number of paths

print("Paths: ", Paths(row,col))

Viruses and Malware Complete the case project on page 82 of the textbook by researching two types of viruses, two types of malware, and two types of denial of service attacks using the internet or any other type of resource available to you. Next, write at least a two page paper in current APA format that lists each of the researched items, how they are used to attack a system or network, and what types of defenses can be put in place to protect against those attacks. Find an article which describes the compromise of a company organization through a virus or malware. Write a one page paper in APA format summarizing the security incident and how it was resolved or what actions could have been taken to prevent it.

Answers

Hi, I provided you a general guide on how to go about your writing your research paper.

Explanation:

Note, the current APA (American Psychological Association) format is the APA 7th Edition. This format details how a researcher should state the findings, sources, conclusion, etc.

Hence, you can begin writing the assigned paper only after gathering the needed data.

Type the correct answer in the box. Spell all words correctly.
John wants to use graphical elements on his web page. Which image formats should he use to keep the file size manageable?
John should use
formats to keep the file size manageable.

Answers

Answer:

PNG, GIF

Explanation:

8. Many organizations build their networks around this type of computer.
A) server
B) terminal
C) supercomputer
heir netwo
of multiple
or that stores data
A)dektop

Answers

it is B) terminal bc There are several different types of computer networks. Computer networks can be characterized by their size as well as their purpose

B is the answer because I looked it up

A project team using a linear, sequential model builds a software application over a long duration. All activities in the project are carried out one after the other. Once the product is tested, the team installs the application. Which phase of this model involves installation?
A.
system design
B.
coding
C.
deployment
D.
requirements gathering
E.
testing

Answers

Answer:

C. Deployment

Explanation:

Deployment is the phase at which the product is installed after testing.

Create a class named TriviaGameV1 that plays a simple trivia game. The game should have five questions. Each question has a corresponding answer and point value between 1 and 3 based on the difficulty of the question. TriviaGameV1 will use three arrays. An array of type String should be used for the questions. Another array of type String should be used to store the answers. An array of type int should be used for the point values. All three arrays should be declared to be of size 5. The index into the three arrays can be used to tie the question, answer, and point value together. For example, the item at index 0 for each array would correspond to question 1, answer 1, and the point value for question 1. Manually hardcode the five questions, answers, and point values in the constructor of TriviaGameV1. The five questions and their corresponding answers are shown on page 3. The point values should be set to 1, 2, 2, 3, 1, respectively.

The class should also provide the following two public methods:

• public boolean askNextQuestion() - This method takes no argument and returns a boolean. If there are no more questions to ask, it returns false. Otherwise, it asks the next question and gets an answer from the user. If the player’s answer matches the actual answer (case insensitive comparison), the player wins the number of points for that question. If the player’s answer is incorrect, the player wins no points for the question and the method will show the correct answer. It returns true after Q & A have been processed.
• public void showScore() - This method takes no argument and returns void. It displays the current score the player receives thus far.

The test driver is provided below, which creates a TriviaGameV1 object. After the player has answered all five questions, the game is over.

public class TriviaGameV1Test {
public static void main(String[] args) { TriviaGameV1 game = new TriviaGameV1();
while (game.askNextQuestion()) game.showScore(); System.out.println("Game over! Thanks for playing!"); }
}

Answers

Answer:

Explanation:

The following code is written in Java, It creates the class for the Trivia game along with the arrays, variables, and methods as requested so that it works flawlessly with the provided main method/test driver. The attached picture shows the output of the code.

import java.util.Arrays;

import java.util.Scanner;

class TriviaGameV1 {

   String[] questions = {"The first Pokemon that Ash receives from Professor Oak is?", "Erling Kagge skiied into here alone on January 7, 1993", "1997 British band that produced 'Tub Thumper'", "Who is the tallest person on record (8 ft. 11 in) that has lived?", "PT Barnum said \"This way to the _______\" to attract people to the exit."};

   String[] answers = {"pikachu", "south pole", "chumbawumba", "robert wadlow", "egress"};

   int[] points = { 1, 2, 2, 3, 1};

   int score;

   int count = 0;

  public void TriviaGameV1() {

       this.score = 0;

  }

  public boolean askNextQuestion() {

      if (count != 5) {

          Scanner in = new Scanner(System.in);

          System.out.println(questions[count]);

          String answer = in.nextLine().toLowerCase();

          if (answer.equals(answers[count])) {

              score += points[count];

          } else {

              System.out.println("Wrong, the correct answer is : " + answers[count]);

          }

          count += 1;

          return true;

      }

      return false;

  }

  public void showScore() {

      System.out.println("Your Score is: " + this.score);

  }

   public static void main(String[] args) {

      TriviaGameV1 game = new TriviaGameV1();

      while (game.askNextQuestion()) {

          game.showScore();

      }

      System.out.println("Game over! Thanks for playing!");

  }

}

What is Requirement Engineering process explain with the help of diagram? Find the functional and non-functional requirements of the given case study.

An automatic ticket issuing system sells rail ticket. User select their destination and input a credit card and a personal identification number. The rail ticket is issued and their credit account charged. When the user presses the start button, a menu display of potential destinations is activated, along with a message to the user to select a destination. Once a destination has been selected, users are requested to input their card. Its validity is checked and user is then requested to input a personal identifier. When the credit transaction has been validated, the ticket is issued

Answers

functional requirement defines a system or its component whereas a non-functional requirement defines the performance attribute of a software system. ... Types of Non-functional requirement are Scalability Capacity, Availability, Reliability, Recoverability, Data Integrity, etc

Which of the following statements is TRUE of a peer-to-peer network?
A. Different parties have very different opinions on what can and can’t be shared through a peer-to-peer network.
B. In a peer-to-peer network, all files being shared are kept on one server. Anyone who wants to access one of those files can get it directly from the server.
C. A peer-to-peer network can create heavy traffic and makes download times increase significantly.
D. Creating a directory of which computers have certain files is an acceptable practice.

Answers

Answer:

A. Different parties have very different opinions on what can and can’t be shared through a peer-to-peer network.

Explanation:
CORRECT
Choice 'A' is very true.
There have been many arguments and court cases over what content can and cannot be shared through a peer-to-peer network. Users of these networks often argue that free speech allows us to share whatever we want online. Content creators on the other hand frequently sue for copyright infringement.


INCORRECT
Choice 'B' is describing a centralized system, not a peer-to-peer network. In a peer-to-peer network, there is no central location of files. Files are transferred directly from one computer to another without a middleman.

Choice 'C' is also not true of peer-to-peer networks. These networks are actually much more efficient than centralized systems because there is no large server holding all the files. It takes less time to download files from a peer-to-peer network because there is no centralized source of information and files.

Choice 'D' is also false; this was decided in the court case about Napster, one of the first large peer-to-peer networks. Having a centralized directory of who has which files is not considered free speech.

The peer-to-peer network is said to have varying views that form the basis of what can and cannot be shared. Thus, option A is correct.

What is a peer-to-peer network?

A peer-to-peer network is given as the connection of the computers that are linked with the following same responsibilities and permissions.

The network is said to have varying views. Many debates and court cases have erupted over what content can and cannot be shared over a peer-to-peer network.

Users of these sites frequently argue that freedom of speech allows us to share whatever we want on the internet.On the other hand, content creators frequently file copyright infringement lawsuits.

Thus, option A is correct.

Learn more about peer-to-peer networks, here:

https://brainly.com/question/1172049

#SPJ2

Why are iterators useful?

Select one:
a. Iterators prevent infinite loops
b. Iterators are easier to loop over than a while loop
c. Iterators walk down a collection faster than a for loop.
d. Iterators give you direct access to private variables.
e. Improve information hiding by not revealing how a collection class is implemented

Answers

It is d because I said it is

Write a program that prints the sum of the even numbers and the products of odd numbers on the screen

Answers

Answer:

The program in Python is as follows:

n = int(input("Number of inputs: "))

total = 0; product = 1

for i in range(n):

   num = int(input(": "))

   if num%2 == 0:

       total+=num

   else:

       product*=num

print("Sum of even: ",total)

print("Product of odd: ",product)

Explanation:

This prompts the user for the number of inputs, n

n = int(input("Number of inputs: "))

This initializes sum (total) to 0 and products to 1

total = 0; product = 1

This iterates through n

for i in range(n):

This gets the inputs

   num = int(input(": "))

If input is even, calculate the sum

   if num%2 == 0:

       total+=num

If otherwise, calculate the product

   else:

       product*=num

Print the required outputs

print("Sum of even: ",total)

print("Product of odd: ",product)

Which is the least technically experienced technical support group?
O tier 2 support
tier 3 support
multi-channel support model
tier 1 support

Answers

Answer:

Tier 1 support

Explanation:

Of the given options, tier 1 support technical group is the least experienced group. This group of technicians is also referred to as level 1 technical group.

The tier 1 or level support are made up of junior technician, and they have few technical understandings.

Their roles include email response and basic troubleshooting, attending to phone calls, among others.

When a problem cannot be solved by tier 1 support  technicians, they pass the problem to tier 2 support technicians,  

Economic Batch Quantity depends on
دی ماه
Material, labour
Set-up costs, carrying
Transportation, carrying
Warehousing, labour​

Answers

Answer: Set-up costs, carrying costs

Explanation:

When it comes to production, the goal is to produce with as little costs as possible so that more profit can be made when the goods are sold.

This is why the Economic Batch Quantity is important. It shows the maximum amount of goods that can be produced in a particular production run such that costs will be minimized.

As such, it is based on the set-up costs of production for that run as well as the carrying costs through the run.

Write a program that randomly (using the random number generator) picks gift card winners from a list of customers (every customer has a numeric ID) who completed a survey. After the winning numbers are picked, customers can check if they are one of the gift card winners. In your main function, declare an integer array of size 10 to hold the winning customer IDs (10 winners are picked). Pass the array or other variables as needed to the functions you write. For each step below, decide what arguments need to be passed to the function. Then add a function prototype before the main function, a function call in the main function and the function definition after the main function.

Answers

Answer:

Explanation:

Since no customer ID information was provided, after a quick online search I found a similar problem which indicates that the ID's are three digit numbers between 100 and 999. Therefore, the Java code I created randomly selects 10 three digit numbers IDs and places them in an array of winners which is later printed to the screen. I have created an interface, main method call, and method definition as requested. The picture attached below shows the output.

import java.util.Random;

interface generateWinner {

   public int[] winners();

}

class Brainly implements generateWinner{

   public static void main(String[] args) {

       Brainly brainly = new Brainly();

       int[] winners = brainly.winners();

       System.out.print("Winners: ");

       for (int x:winners) {

           System.out.print(x + ", ");

       }

   }

   public int[] winners() {

       Random ran = new Random();

       int[] arr = new int[10];

       for (int x = 0; x < arr.length; x++) {

           arr[x] = ran.nextInt(899) + 100;

       }

       return arr;

   }

}

The EDI ____________layer describes the business application that i
driving EDI
a)EDI Semantic Layer c) EDI Transport Layer
b) EDI Standard Translation Layer d) Physical Layer

Answers

Answer:

a) EDI Semantic Layer

Explanation:

EDI is an acronym for electronic data interchange and it can be defined as a form of communication between interconnected computer systems and software applications with respect to business informations in standard digital formats.

This ultimately implies that, electronic data interchange (EDI) involves the transfer of business informations such as financial transactions between the computer systems of various organizations such as banks, companies, governmental agencies, etc. Thus, it avails businesses the ability to create strategic communications using computer to computer links to effectively and efficiently exchange business informations electronically or in digital formats.

Hence, the EDI Semantic layer describes the business application that is driving electronic data interchange (EDI).

-1
Draw a flowchart to input two
numbers in variables M and N and
print the multiplication table from 1*1
to M*N​

Answers

Answer:A flowchart is a diagram that depicts the steps involved in solving a problem. The following flowchart shows how to output the multiplication table ( n * 1 to m * 1) of a number, n and m:

How can presentation software be used in a
business or professional setting? Choose all that
apply.
to automate the ticket-purchasing process at
movie theaters through a kiosk
to teach lessons to high school students
to deliver a sales presentation to clients
to create charts and graphs from a table of
values
to compose letters and memos
DONE

Answers

Answer:

To automate the ticket purchasing process at the movie theaters through a kiosk

To teach lessons to high school students

To deliver a sales presentation to clients

Explanation:

I just used the answers above and got 2/3 wrong and edge said so

recent trends on operating system

Answers

Answer:

Windows 10 if this is what I think u mean

which shortcut can we use to make directional heading of a cuboid more obvious while in the lidar view​

Answers

Answer:

cutting across

Explanation:

Dante needs to query a table to find all the references to a particular product and apply a 10%
discount. Which query should he utilize?
O make table query
O delete query
O update query
O append query

Answers

Answer:

update query

I hope this helps a little bit.

Answer:

update query

Explanation:

took the test

Manny has drafted an email message and configured a delivery option "Do not deliver before: 5:00 P.M. and today's date." He shuts down his computer and leaves for the day at 4:30 p.m. What will happen at 5 p.m.?

Answers

Answer:

The Email will send.

Explanation:

The email will send as long as there is internet connection.

Answer: this isnt an answer but i really need ur help.. did u pass the microsoft unit test? I cant pass it if my life depended on it

Explanation:

Its on edge

calculate the total and average number from 1 to 100

Answers

Answer:

Thus, 50.5 is an average of numbers from 1 to 100.

Explanation:

getcalc.com's average calculator to find what is the mean or average of natural numbers upto 100.

50.5 is an average of numbers from 1 to 100 mentioned in the below table, by substituting the total sum and count of numbers in the below formula. The corresponding formulas, chart, examples & workout may help students, teachers or professionals to learn, teach or practice the average of natural numbers upto 100.

Address the formula, input parameters & values.

Formula: Average = Total Sum of Numbers / Total Count of Numbers

Input parameters & values:

The numbers from 1 to 100 are

1, 2, 3, 4, . . . . , 98, 99, 100

Total Count of Numbers = 100

step 2 Find the sum of numbers from 1 to 100.

sum = 1 + 2 + 3 + . . . . + 99 + 100

= 5050

step 3 Divide the sum by 100 Average = 5050/100 = 50.5

Thus, 50.5 is an average of numbers from 1 to 100.

g Write a function called chain_words(str) which takes in one parameter which is a string that holds multiple words separated by spaces. Your function should return a string with the words chained together with an - (hyphen). You can first split the words at spaces and then join the words with - (hyphen). You can achieve this by using split and join methods respectively.

Answers

Answer:

Explanation:

The following is written in Python. The function takes in a string as a parameter. It then sperates the string at every space. Then it rejoins the list of strings with hyphens. Finally, returning the newly created string with hyphens.

def chain_words(str):

   string_split = str.split(" ")

   seperator = '-'

   hyphen_string = seperator.join(string_split)

   return hyphen_string

a) Why is eavesdropping done in a network?
b) Solve the following using checksum and check the data at the
receiver:
01001101
00101000​

Answers

Answer:

An eavesdropping attack is the theft of information from a smartphone or other device while the user is sending or receiving data over a network.

Missing: checksum ‎01001101 ‎00101000

17. What are the basic modes of operation of 8255?Write the features of mode 0 in 8255?

Answers

Answer:

There are two basic operational modes of 8255:

Bit Set/Reset mode (BSR mode).

Input/Output mode (I/O mode).

Features of 8255 Microprocessor:

Mode 0 : Simple Input/Output.

Mode 1 : Input/Output with handshake.

Mode 2 : Bi-directional I/O data transfer.

It has three 8-bit ports : Port A, Port B, and Port C, which are arranged in two groups of 12 pins.

The 8255 can operate in 3 I/O modes : (i) Mode 0, (ii) Mode 1, & (iii) Mode 2.

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. g

Answers

Answer:

The program in Python is as follows:

string = input("String: ")

chr = input("Character: ")[0]

total_count = string.count(chr)

print(total_count,end=" ")

if total_count > 1:

   print(chr+"'s")

else:

   print(chr)

Explanation:

This gets the string from the user

string = input("String: ")

This gets the character from the user

chr = input("Character: ")[0]

This counts the occurrence of the character in the string

total_count = string.count(chr)

This prints the total count of characters

print(total_count,end=" ")

If the count is greater than 1

if total_count > 1:

Then it prints a plural form

   print(chr+"'s")

If otherwise

else:

Then it prints a singular form

   print(chr)

Your systems analysis team is close to completing a system for Azuka Theatre. Kevin is quite con- fident that the programs he has written for Azuka's inventory system used for keeping track of stage scenery and props will perform as required because they are similar to programs he has done before. Your team has been very busy and would ideally like to begin full systems testing as soon as possible. Mark and Allison, two of your junior team members have proposed the following:
a. Skip desk checking of the programs (because similar programs were checked in other installa- tions; Kevin has agreed).
b. Do link testing with large amounts of data to prove that the system will work.
c. Do full systems testing with large amounts of live data to show that the system is working. Respond to each of the three steps in their proposed test schedule. Use a paragraph to explain your response.

Answers

Answer:

a

Explanation:

im smart

Desk checking is a method to check the logic of an algorithm by manually working through it. There are many reasons for Desk Checking that may be omitted or simplified.

What are the reasons for desk checking?

If the current program’s logic is identical, then this step may be omitted; this, however, implies some effort to verify “sameness.” If truly identical, perhaps there is re-usable code, or the code to be developed should become a reusable library routine.

Link testing is the testing of the group of modules in order to ensure that the modules operate correctly in combination. It generally verifies that the function or operation is executed properly. System testing is a type of testing that is used to confirm the actual function of the system in which a work is executed or performed.

Therefore, all of the testing mechanisms are well described above.

To learn more about System and link testings, refer to the link:

https://brainly.com/question/7658665

#SPJ2

You are an IT network administrator at XYZ Limited. Your company has critical applications running of its Ubuntu Linux server. Canonical, the company that owns and maintains Ubuntu just releases an update to patch a security vulnerability in the system.

Required:
What BEST action you should take?

Answers

Answer:

Explanation:

I believe that the best course of action would be to divide the companies computers and run the critical applications on half of the systems while the other half update to the latest Ubuntu release. Once that half is done updating, you run the applications on the updated systems and update the other half of the systems. This will allow the company to continue its operations without any downtime, while also updating to the latest Ubuntu release on all systems and making sure that all systems do not have any security vulnerabilities due to outdated software.

What symbol next to the records indicates that a table includes a subdatasheet? an asterisk a plus sign a question mark an exclamation point

Answers

Answer: a plus sign

Explanation: I just did the assignment and got it right

Answer:

B)A plus sign

Explanation:

B)A plus sign just finished assignment

Other Questions
What is the number of moles in 4.81 L of H2S gas at STP? What is the answer to this problem Select the correct answer from each drop-down menu.established missions around the world and helped spread Where was gatsby really born Fix the one word that is used incorrectly.CanyoutakeawrenchwhenyoucomeoverMrMcClainaskedAlvinWe'llneedittofixtheleakypipeinthekitchen 4x6=5y+2Write a formula for g(x), in terms of x.Please What consists of all the living organisms in an area and thenon-living aspects of the environment?a Ecosystemb CommunityC Population what is the relationship between the density of a liquid and it's upthrust?plz help me As the president of your schools student council, it is your responsibility to plan the upcoming school dance. Write five sentences asking students to do what you have planned for the dance. Write t commands about what they need to do before, during and after the dance to ensure that the event runs smoothly.Performance Checklist(2 Points) Your list is written entirely in Spanish and contains at least five total tasks.(2 Points) You properly use the t command form at least three times.(2 Points) Your information is organized by before (antes), during (durante) and after (despus).(2 Points) You have no more than five mistakes in spelling and grammar.(2 Points) Your list uses proper capitalization and punctuation of sentences. y is an integer. Write down all the solutions of the inequality. -8 < 2y < 0 The volume of a cuboid is 176cmThe length is 11 cm and the width is 20mmWork out the height of the cuboid in cm. Explain ONE way in which policies to maintain global influence in the United States were similar to the policies to maintain global influence in the Soviet Union. Jordan wants to research how cryptocurrencies are affecting worldwide financial systems.Which search terms would most effectively yield results from an online search?a. cryptocurrencies financial impactb. number of Bitcoin systemsc. How do cryptocurrencies affect financial systems?d. the impact of Bitcoin on world finances Which is an example of a statistical question?QuestionsQuestion 1 How many pets does Alisha have at home?Question 2 How old were you when you got your first pet?Question 3 Do you like having a pet?Question 4 What is Alishas pets name?A question 1B question 2C question 3D question 4 Which of these is a reason why people wanted to move out west in the mid-1800s?A) to take advantage of cheap or free landB) to escape religious persecution C) to find jobsD) all of the aboveAnswer: D) all of the above Jessica's bedroom is 17 feet long and 9 1/2 feet wide. What is the area of the bedroom? Circle O has a arc length 34 inches sub tended by an angle of 78 degrees. Find the length of the radius, x, to the nearest tenth of an inch Who Became Emperor of France in 1852 * Earthworms help farmers. Many farmers add them to their farmland because they help form rich soil to grow crops in.Earthworms mix different layers of soil together by carrying humus from the surface down into the subsoil. Humus is a dark-colored substance made up of a variety of materials. Which two of the following are found in humus? NO LINKS OR WILL BE REPORTED PLEASE HELP ASAP WILL MARK BRAINLIEST