Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a Python program with the following functions: 1. findElement( ) : This function accepts an input string and an index value as input

Please write a Python program with the following functions: 1. findElement( ) : This function accepts an input string and an index value as input parameters. It returns the element at the specified index value within the input string. For example: findElement(string,0) returns T where string = Teststring. 2. concatString( ): This function accepts two strings as input and concatenates them using the + operator. The + operator works as shown in the example below: >>> str1 = "A sample string" >>> str2 = "...concatenated with another sample string" >>> str1 + str2 'A sample string...concatenated with another sample string 3. divideString( ): This function accepts ONLY an input string and returns the first half of the input string. You can use the len function in Python to get the length of the input string as shown below: >>> str1 = "A sample string" >>> len(str1) 15 string[start index value : end index value] returns a part of a string from a user-specified start index value to a user-specified end index value. Look at the example below for more

clarification: >>> str1 = "A sample string" >>> str1[0:5] 'A sam Note that an index value must be an integer. You will be required to import the math library and use the floor function to convert the half of your string length to the nearest integer. To test your functions using the following test code: inputString1 = "This is a test string" inputString2 = "...it tests your functions" inputString3 = "functions" print(findElement(inputString1, 0)) print(concatStrings(inputString1, inputString2)) print(sliceStrings(inputString1)) print(findSubstring(inputString2, inputString3)) print(findSubstring(inputString1, inputString3)) Output from this test code: T This is a test string...it tests your functions This is a True False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago