1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lora16 [44]
3 years ago
9

Python program

Computers and Technology
1 answer:
Serhud [2]3 years ago
7 0

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

You might be interested in
Explain about third generation of computer​
diamong [38]

Answer:

The period of third generation was from 1965-1971. The computers of third generation used Integrated Circuits (ICs) in place of transistors. ... This development made computers smaller in size, reliable, and efficient. In this generation remote processing, time-sharing, multiprogramming operating system were used.

Explanation:

hope it helps

6 0
3 years ago
BRAINLIESTTTT How does a project manager evaluate the scope of a project?
Leokris [45]

Answer:

The first choice

Explanation:

I took the test and that was the correct answer

Hope it helped!

5 0
3 years ago
The proper hand position for keyboarding.
mr_godi [17]

Left fingers on ASDF whilst right hand is on jkl;

A= pinkie

S= ring finger

D=Middle

F=Index.

J=Index.

K=Middle

K=Ring finger

;= pinkie

Hope this helped

5 0
4 years ago
When you get ###### or 1.1E+13 as a result in a cell, it means:
Zigmanuir [339]
This simply means that the cell is not wide enough to be able to show all the contents entered into that cell
7 0
3 years ago
John is a mechanical engineer. His first task at his job is to build any microphone of his choice. He chooses to build a dynamic
Jobisdone [24]

Answer:

A. simple to construct and easy to repair

Explanation:

A dynamic microphone works on the principle of electromagnetic principle. A diaphragm is attached to a coil of wire which helps in producing sound. Responding to the sound waves, the coil of the wire is vibrated by the diaphragm.  A magnetic field is created by the magnet which is present inside the coil of wire. The electrical signal is generated in response to the motion of the coil. The speed of the motion produces the amount of the current.

Since the construction of a dynamic microphone is easier as compared to any other microphone, John is likely to opt to build one.

7 0
3 years ago
Other questions:
  • When you reboot your system, the computer follows start-up instructions stored in this type of memory. multiple choice dram sdra
    15·2 answers
  • ____ are not associated with data from the database and are used to display such things as the report's title
    15·1 answer
  • What type of graphic organizer will help jane compare the results of a student survey about teachers at her school?
    15·2 answers
  • WILL GIVE BRAINLIEST TO HELPFUL ANSWERS!
    8·1 answer
  • Jane is creating a slide that will have a large heading and number of bullet points below it. What slide format should she use?
    12·1 answer
  • Citing Wikipedia as a reference is not considered a good practice because 1.leverages a neutral point of view. 2.hosts unopinion
    8·1 answer
  • A person is trying to remember a list of 12 different items:
    6·2 answers
  • Difference between hardcopy and hardware​
    6·1 answer
  • How to delete brackets in string java.
    9·1 answer
  • What made the master so angry with his servant?​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!