answer.
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
PtichkaEL [24]
1 year ago
14

#Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The fun

ction will look for the search string within the #target string. # #The function should return a string representing where in #the target string the search string was found: # # - If search string is at the very beginning of target # string, then return "Beginning". For example: # string_finder("Georgia Tech", "Georgia") -> "Beginning" # # - If search string is at the very end of target string, # then return "End". For example: # string_finder("Georgia Tech", "Tech") -> "End" # # - If search string is in target string but not at the # very beginning or very end, then return "Middle. For # example: # string_finder("Georgia Tech", "gia") -> "Middle" # # - If search string is not in target string at all, then # return "Not found". For example: # string_finder("Georgia Tech", "Idaho") -> "Not found" # #Assume that we're only interested in the first instance #of the search string if it appears multiple times in the #target string, and that search string is definitely #shorter than target string. # #Hint: Don't be surprised if you find that the "End" case #is the toughest! You'll need to look at the lengths of #both the target string and the search string. #Write your function here!

Computers and Technology
1 answer:
adoni [48]1 year ago
6 0

Answer:

I am writing a Python program:

def string_finder(target,search): #function that takes two parameters i.e. target string and a search string

   position=(target.find(search))# returns lowest index of search if it is found in target string

   if position==0: # if value of position is 0 means lowers index

       return "Beginning" #the search string in the beginning of target string

   elif position== len(target) - len(search): #if position is equal to the difference between lengths of the target and search strings

       return "End" # returns end

   elif position > 0 and position < len(target) -1: #if value of position is greater than 0 and it is less than length of target -1

       return "Middle" #returns middle        

   else: #if none of above conditions is true return not found

       return "not found"

#you can add an elif condition instead of else for not found condition as:

#elif position==-1    

#returns "not found"

#tests the data for the following cases      

print(string_finder("Georgia Tech", "Georgia"))

print(string_finder("Georgia Tech", "gia"))

print(string_finder("Georgia Tech", "Tech"))

print(string_finder("Georgia Tech", "Idaho"))

Explanation:

The program can also be written in by using string methods.

def string_finder(target,search):  #method definition that takes target string and string to be searched

       if target.startswith(search):  #startswith() method scans the target string and checks if the (substring) search is present at the start of target string

           return "Beginning"  #if above condition it true return Beginning

       elif target.endswith(search):  #endswith() method scans the target string and checks if the (substring) search is present at the end of target string

           return "End" #if above elif condition it true return End

       elif target.find(search) != -1:  #find method returns -1 if the search string is not in target string so if find method does not return -1 then it means that the search string is within the target string and two above conditions evaluated to false so search string must be in the middle of target string

           return "Middle"  #if above elif condition it true return End

       else:  #if none of the above conditions is true then returns Not Found

           return "Not Found"

You might be interested in
Drag each tile to the correct box.
garri49 [273]
I think select the video insert select the movie option under illustrations resize the video player then select the insert tab i’m not 100 percent sure tho
8 0
2 years ago
Read 2 more answers
In one to three sentences describe one reason you would import data into a datebase
Bond [772]

The primary reason that you would import data into a database is because the data already exists somewhere else.

As an example, you may have a spreadsheet that contains names and telephone numbers of a group of people. It is much faster to import this data into a database instead of manually entering the information.

8 0
2 years ago
Hybrid processors that can process 32 bits or 64 bits are known by what term?
patriot [66]
For the answer to the question above asking, what h<span>ybrid processors that can process 32 bits or 64 bits are known by what term?

I think you are referring to the Chipset. and they are Manufactured by Intel and Advance Micro Devices (AMD). Intel's Pentium is the first one to have 32 bits and 64 bits of processors.</span>
4 0
1 year ago
Write a for loop that iterates from 1 to numbersamples to double any element's value in datasamples that is less than minvalue.
CaHeK987 [17]

Answer:

function dataSamples=AdjustMinValue(numberSamples, userSamples, minValue)

dataSamples=userSamples;

%for loop

for i=1:numberSamples

%checking if dataSamples value at index,i

%is less than minValue

if dataSamples(i)<minValue

%set double of dataSamples value

dataSamples(i)= 2*dataSamples(i);

end

end

end

Explanation:

The given code is in MATLAB.

4 0
1 year ago
In computing, a(n) _____ is an attack on an information system that takes advantage of a particular system vulnerability. Select
tensa zangetsu [6.8K]

Answer: d) Exploit

Explanation: Exploit is a type computer attack that successful when the computer system of an user is vulnerable and attacker can do the exploitation. This happens due to the weakness of the system, applications software, network etc.

Other given option are incorrect because exit door,glitch and bad are not any type of attack in the computer field that causes harm to the system.Thus the correct option is option(d).

4 0
1 year ago
Other questions:
  • Mechanical advantage is the ratio of the force required to move a load divided by______
    12·1 answer
  • Which type of utp cable is used to connect a pc to a switch port?
    10·1 answer
  • If you have long column labels with columns so wide that they affect the readability of a worksheet, you should first
    7·1 answer
  • Eric is working on a computer that has a device driver error. Eric can find the name of the device driver however the actual dev
    9·2 answers
  • Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
    15·1 answer
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • The variable grade can have any real number value from 0 to 100. Ask the user to enter a grade in numerical form. Write an if-el
    9·1 answer
  • .Ten pounds of candy were prepared for the school party.
    10·1 answer
  • In cell M2, enter a formula using a nested IF function as follows to determine first if a student has already been elected to of
    12·1 answer
  • You would like the user of a program to enter a customer’s last name. Write a statement thaUse the variables k, d, and s so that
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!