#Write a function called string_finder. string_finder should #take two parameters: a target string and a search string. #The function 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!

Answers

Answer 1
Answer:

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"


Related Questions

A customer contacts the help disk stating a laptop does not remain charged for more than 30 minutes and will not charge more than 15%. Which of the following components are the MOST likely causes the issue? (Select three.)A. LCD power inverterB. AC adapterC. BatteryD. ProcessorE. VGA cardF. MotherboardG. Backlit keyboardH. Wireless antenna
.Although SQL is a language, you donĂ¢t use it to write applications? (true, false)
A ____ statement is a a control flow statement that repeatedly executes a statement or a series of statements while the value of a specific condition is truthy or until the value of a specific condition becomes truthy.a. decision-makingb. forkc. breakd. loop
_ is an important management tool that is used to monitor and manage that contract and/or project
True / FalseIn the structure of a conventional processor, the computational engine is generally known as the arithmetic-logic unit.

Assume there is a machine with the IP address 129.82.102.63 with netmask /23, and with a parent NW whose netmask is 255.255.224.0. For each answer, do not include any spaces, give full IP addresses/netmasks where these are requested, give the "/" as part of the answer for slash notation.

Answers

Complete question is:

Assume there is a machine with the IP address 129.82.102.63 with netmask /23, and with a parent NW whose netmask is 255.255.224.0.

For each answer, do not include any spaces, give full IP addresses/netmasks where these are requested, give the "/" as part of the answer for slash notation.

a. What is the parent NW's netmask in dotted decimal notation?  

b. What is the parent NW's netmask in slash notation?  

c. What is the child NW's (subnet's) netmask in dotted decimal notation?  

d. What is the child NW's (subnet's) netmask in slash notation?  

e. How many bits are there for host # portion for the parent NW? (Another way to say the same thing is How many bits do we manage - on the parent NW?)  

f. How many bits are there for NW# portion (within the parent address space) for the subnet?

g. How many bits are there for host # portion for the subnet?  

h. How many addresses can we assign to machines/interfaces on this subnet?

Answer:

a. 255.255.224.0

b. /19

255.255 amounts to 16 bits being 1. .224 means 3 more bits are 1. So, in total 19 bits are 1. Hence, total network bits are 16 + 3 = 19.

c. 255.255.254.0

/23 means 8 + 8 + 7 that means

first 2 octets are 1s and 7 bits out of the 3rd octet are 1s. Hence, /23 means 255.255.254.0

d. /23

e. 13 bits are reserved for hosts

Parent network mask is /19, so total 32-19 = 13 bits

f. 19 bits are reserved for the network in the parent address.

g. 9 bits

Subnetwork's mask is /23, so total 32-23 = 9 bits for the host portion.

h. Since 9 bits are reserved for hosts, a total of 29 -2 = 510 machines can be assigned the IP addresses. Two addresses will be network and broadcast addresses for the subnet that can't be allocated to any device.

Explanation:

You are tasked with writing a program to process sales of a certain commodity. Its price is volatile and changes throughout the day. The input will come from the keyboard and will be in the form of number of items and unit price:36 9.50which means there was a sale of 36 units at 9.50. Your program should read in the transactions (Enter at least 10 of them). Indicate the end of the list by entering -99 0. After the data is read, display number of transactions, total units sold, average units per order, largest transaction amount, smallest transaction amount, total revenue and average revenue per order.

Answers

Answer:

Here the code is  given as,

Explanation:

Code:

#include <math.h>

#include <cmath>  

#include <iostream>

using namespace std;

int main() {

int v_stop = 0,count = 0 ;

int x;

double y;

int t_count [100];

double p_item [100];

double Total_rev = 0.0;

double cost_trx[100];

double Largest_element , Smallest_element;

double unit_sold = 0.0;

for( int a = 1; a < 100 && v_stop != -99 ; a = a + 1 )

  {

     cout << "Transaction # " << a << " : " ;

     cin >> x >> y;

 

  t_count[a] = x;

  p_item [a] = y;

  cost_trx[a] = x*y;

 

  v_stop = x;

  count = count + 1;

 

  }

 

  for( int a = 1; a < count; a = a + 1 )

  {

   Total_rev = Total_rev + cost_trx[a];

   unit_sold = unit_sold + t_count[a];

  }

 

  Largest_element = cost_trx[1];

  for(int i = 2;i < count - 1; ++i)

   {

      // Change < to > if you want to find the smallest element

      if(Largest_element < cost_trx[i])

          Largest_element = cost_trx[i];

   }

Smallest_element = cost_trx[1];

  for(int i = 2;i < count - 1; ++i)

   {

      // Change < to > if you want to find the smallest element

      if(Smallest_element > cost_trx[i])

          Smallest_element = cost_trx[i];

   }

  cout << "TRANSACTION PROCESSING REPORT     " << endl;

  cout << "Transaction Processed :           " << count-1 << endl;

  cout << "Uints Sold:                       " << unit_sold << endl;

  cout << "Average Units per order:          " << unit_sold/(count - 1) << endl;

  cout << "Largest Transaction:              " << Largest_element << endl;

  cout << "Smallest Transaction:             " << Smallest_element << endl;

  cout << "Total Revenue:               $    " << Total_rev << endl;

  cout << "Average Revenue :            $    " << Total_rev/(count - 1) << endl;

   

  return 0;

 

}

Output:

Write a python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. There are 12 students in the class. Write the following functions in the program:
calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student
determine_grade - this function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale:
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F

Answers

In this exercise we have to use the computer language knowledge in python to write the code as:

the code is in the attached image.

In a more easy way we have that the code will be:

def calc_average(name):

  score = []

  sum = 0

  for j in range(8):

      inp = int(input("Test Score"+str(j+1)+": "))

      score.append(inp)

      sum = sum + inp

      if inp>=90 and inp<=100:

          print("A")

      elif inp>=80 and inp<90:

          print("B")

      elif inp>=70 and inp<80:

          print("C")

      elif inp>=60 and inp<70:

          print("D")

      else:

          print("F")

  avg = sum/8

  print("Result Details of "+name)

  print("Average Score: "+str(avg))

  return avg

def determine_grade(result):

  if float(result) >= 90.0 and float(result) <= 100.0:

      print("Letter Grade: A")

  elif float(result) >= 80.0 and float(result) <90.0:

      print("Letter Grade: B")

  elif float(result) >= 70.0 and float(result) < 80.0:

      print("Letter Grade: C")

  elif float(result) >= 60.0 and float(result) < 70.0:

      print("Letter Grade: D")

  else:

      print("Letter Grade: F")

  print(" ")

for i in range(2):

  name = input("Student Name: ")

  result = calc_average(name)

  determine_grade(result)

See more about python at brainly.com/question/26104476

Answer:

The program doesn't make use of comments (See Explanation)

Also the source code is attached as image to enable you see the proper format and indexing of the source code

The program using python is as follows

def calc_average(name):

   score = []

   sum = 0

   for j in range(8):

       inp = int(input("Test Score"+str(j+1)+": "))

       score.append(inp)

       sum = sum + inp

       if inp>=90 and inp<=100:

           print("A")

       elif inp>=80 and inp<90:

           print("B")

       elif inp>=70 and inp<80:

           print("C")

       elif inp>=60 and inp<70:

           print("D")

       else:

           print("F")

   avg = sum/8

   print("Result Details of "+name)

   print("Average Score: "+str(avg))

   return avg

def determine_grade(result):

   if float(result) >= 90.0 and float(result) <= 100.0:

       print("Letter Grade: A")

   elif float(result) >= 80.0 and float(result) <90.0:

       print("Letter Grade: B")

   elif float(result) >= 70.0 and float(result) < 80.0:

       print("Letter Grade: C")

   elif float(result) >= 60.0 and float(result) < 70.0:

       print("Letter Grade: D")

   else:

       print("Letter Grade: F")

   print(" ")

for i in range(2):

   name = input("Student Name: ")

   result = calc_average(name)

   determine_grade(result)

Explanation:

def calc_average(name):  -> Declares the function calc_average(name); It accepts local variable name from the main function

   score = []

-> Initialize an empty list to hold test scores

   sum = 0

-> Initialize sum of scores to 0

   for j in range(8):

-> Iterate from test score 1 to 8

       inp = int(input("Test Score"+str(j+1)+": "))

-> This line accepts test score from the user

       score.append(inp)

-> The user input is then saved in a lisy

       sum = sum + inp

-> Add test scores

The following lines determine the letter grade of each test score      

if inp>=90 and inp<=100:

           print("A")

---

      else:

           print("F")

   avg = sum/8  -> Calculate average of the test score

The next two lines prints the name and average test score of the student

   print("Result Details of "+name)

   print("Average Score: "+str(avg))

   return avg

-> This line returns average to the main method

The following is the determine_grade method; it takes it parameter from the main method and it determines the letter grade depending on the calculated average

def determine_grade(result):

   if float(result) >= 90.0 and float(result) <= 100.0:

       print("Letter Grade: A")

   elif float(result) >= 80.0 and float(result) <90.0:

       print("Letter Grade: B")

   elif float(result) >= 70.0 and float(result) < 80.0:

       print("Letter Grade: C")

   elif float(result) >= 60.0 and float(result) < 70.0:

       print("Letter Grade: D")

   else:

       print("Letter Grade: F")

   print(" ")

for i in range(2):

-> This is the main method

   name = input("Student Name: ")  -> A local variable stores name of the student

   result = calc_average(name)  -> store average of scores in variable results

   determine_grade(result)-> Call the determine_grade function

In a clustered column chart, the names of each column are part of the ____ series. select one:a. category
b. data
c. label
d. legend

Answers

data.......;...............;.........;......;.
Hello RandomHacker

Answers: In a clustered column chart, the names of each column are part of the data series. 

Hope That helps
-Chris

A mobile device user is having problems launching apps and texting. The user touches an app to launch it, but the app icon next to the desired app launches instead. When the user types a text message, every word in the message is misspelled. What is the most likely cause for this behavior?

Answers

Answer:

The screen protector may be interfering with the touch response

Explanation:

Screen protectors or commonly called screen guards are used to protect phone screens. In case they fall to the ground, these protectors act as shields to keep the phone screen from getting damaged. However screen protectors if not positioned or fixed properly may also cause hindrance to effective touch response as they become barriers to the touch screen.

Write a program that takes an integer as input, representing a year in school. Output "Elementary school" for 0-5, "Middle school" for 6-8, "High school" for 9-12, "College" for 13-16, and "Post-secondary" for 17 and higher. Output "Invalid" for negative input. If the input is 7, the output is:

Answers

In python:

year = int(input("Enter the school year: "))

if 0 <= year <= 5:

   print("Elementary school")

elif 6 <= year <= 8:

   print("Middle school")

elif 9 <= year <= 12:

   print("High School")

elif 13 <= year <= 16:

   print("College")

elif year >= 17:

    print("Post-secondary")

else:

   print("Invalid")

I hope this helps!