This program, called SubstringFinder2, finds a target string in a source string and returns the inder...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This program, called SubstringFinder2, finds a target string in a source string and returns the inder of the first character of target in source. SubstringFinder2 works as follows: SubstringFinder2 takes a string called source as the first input. Then, the program takes the string target as the second input. SubstringFinder2 is supposed to check if target is a substring of source, and if yes, it returns the index of the first character of target where it appears in source. If target does not appear in source, SubstringFinder2 prints -1. In developing SubstringFinder2, you are not allowed to use any Python built-in methods --, or user-defined modules. Instead, you have to use the basic knowledge of string processing such as the index operator, the slice operator, and string comparisons. You can see examples of SubstringFinder2 input and output in Table 2. Note that your program input and output format should be exactly the same as the format of the examples shown in Table 2. Example 1 abcabdab cab 2 Table 2: The SubstringFinder2 Sample Input and Output Example 3 hhgywshxns Example 2 sfuisauni sau 4 WSX -1 Example 4 yyyyyyy yyyy 0 This program, called SubstringFinder2, finds a target string in a source string and returns the inder of the first character of target in source. SubstringFinder2 works as follows: SubstringFinder2 takes a string called source as the first input. Then, the program takes the string target as the second input. SubstringFinder2 is supposed to check if target is a substring of source, and if yes, it returns the index of the first character of target where it appears in source. If target does not appear in source, SubstringFinder2 prints -1. In developing SubstringFinder2, you are not allowed to use any Python built-in methods --, or user-defined modules. Instead, you have to use the basic knowledge of string processing such as the index operator, the slice operator, and string comparisons. You can see examples of SubstringFinder2 input and output in Table 2. Note that your program input and output format should be exactly the same as the format of the examples shown in Table 2. Example 1 abcabdab cab 2 Table 2: The SubstringFinder2 Sample Input and Output Example 3 hhgywshxns Example 2 sfuisauni sau 4 WSX -1 Example 4 yyyyyyy yyyy 0
Expert Answer:
Answer rating: 100% (QA)
Read the two stringssrc inputtarget input Initialize the index variable to 1 ... View the full answer
Related Book For
Modern Advanced Accounting in Canada
ISBN: 978-1259087554
8th edition
Authors: Hilton Murray, Herauf Darrell
Posted Date:
Students also viewed these programming questions
-
These quotes apply to all problems UNLESS stated otherwise. The time period is 1 year for all problems. NOK - Norwegian krona. The quotes are fictitious. Current interest rates are very different....
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Question 2: Consider the market for Florida oranges. The demand for Florida oranges is given by the inverse demand function p = 70-2Q The market cost function for firms that sell Florida oranges is...
-
A spacecraft approaching the planet Saturn reaches point A with a velocity vA of magnitude 21 km/s. It is placed in an elliptic orbit about Saturn so that it will be able to periodically examine...
-
What is the effect on a bonds duration of increasing the bonds maturity? As in the previous example, use a numerical example and plot the answer. Note that as N , the bond becomes a consol (a bond...
-
Describe the different types of events and compare them.
-
CMD Asset Management has the following fee structure for clients in its equity fund: 1.00% of first $5 million invested 0.75% of next $5 million invested 0.60% of next $10 million invested 0.40%...
-
Suppose the spot exchange rate is 0.6993 GBP/CAD. The exchange rate volatility is 20%. Assume that the interest rates in Canada and U.K. are 4.5% and 6%, respectively. What is the price of a...
-
Determine the moments of inertia I x and I y of the area shown with respect to centroidal axes respectively parallel and perpendicular to side AB. 60 mm 320 mm 40 mm so mm 80 inm 330 mm 80 mm
-
QUESTION 5 Not yet answered Marked out of 2.00 P Flag question The main advantage of fluorescence over UV-Vis spectroscopy is Select one: a. Its sensitivity because fluorescence is measured by...
-
The comparative statements of Bramble Company are presented here. Bramble Company Income Statements For the Years Ended December 31 2022 2021 Net sales $1,814,500 $1,750,100 Cost of goods sold...
-
a. Net income was $476,000. b. Issued common stock for $75,000 cash. c. Paid cash dividend of $16,000. d. Paid $130,000 cash to settle a long-term notes payable at its $130,000 maturity value. e....
-
On January 1, Year 8, T-Best Corporation issued $10 million face value, 10-year bonds. The bonds carry a stated interest rate of 6 percent per year, payable semiannually on June 30 and December 31....
-
Oriole Taffy Inc. manufactures an high-speed candy making machine with an estimated life of 10 years and leases it to Waterway Candy for a period of 8 years. The normal selling price of the machine...
-
Stuff Company is a subsidiary of Pland Corporation and is located in Madrid, Spain, where the currency is the euro (). Data on Stuff's inventory and purchases are as follows: Inventory, January 1,...
-
Calculate the work W done by the gas during process 12651. 2P0 Po 51 Vo 4 6: 2V 3Vo - V
-
Draw the appropriate control flow graph of the given pseudocode.Make sure to only use one number for blocks of code which are all sequential and when the first line is executed, all of those lines...
-
Large Ltd. purchased 70% of Small Company on January 1, Year 6, for $770,000, when the statement of financial position for Small showed common shares of $560,000 and retained earnings of $260,000. On...
-
Prepare the memo requested by the CFO. Ignore income taxes. P Co. is looking for some additional financing in order to renovate one of the company's manufacturing plants. It is having difficulty...
-
Does the FCT method use the same unit of measure as the PCT method? Explain.
-
The von Neumann entropy satisfies a further inequality among three systems called strong subadditivity. \({ }^{20}\) As with subadditivity, strong subadditivity is only a property of the von Neumann...
-
We had stated in this chapter that the general Rnyi entropies do not satisfy subadditivity; only the von Neumann entropy does. In Example 12.2 , we constructed an explicit counterexample for the Rnyi...
-
In our analysis of hydrogen in Chap. 9, we discussed the period of recombination, the time in the history of the universe at which protons and electrons became bound and formed neutral hydrogen. We...
Study smarter with the SolutionInn App