Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Download lab 4 . py and rename it according to the instructions above. Modify the program by adding the four missing functions. The functions are
Download labpy and rename it according to the instructions above.
Modify the program by adding the four missing functions. The functions are described in the grading section below.
If the missing functions are implemented correctly, this output will appear when the user enters how now brown cow for the first string and ow for the second string. Note: Your solution should work for any pair of strings.
output:
Enter a first string: how now brown cow
Enter a second string: ow
String Concatenation Testing
Using builtin : how now brown cowow
Using concatenationloop function: how now brown cowow
Using concatenationrecursion function: how now brown cowow
Occurences of Second String in First String Testing
Using builtin count:
Using occurrencesloop function:
Using occurrencesrecursion function:
full code:
### main
def main:
This tests the four required functions. Do not change this code.
printCSCI Lab
print
string inputEnter a first string: lower
string inputEnter a second string: lower
print
String Concatenation Testing"
print
printUsing builtin : string string
printUsing concatenationloop function:
concatenationloopstring string
printUsing concatenationrecursion function:
concatenationrecursionstring string
###
print
Occurences of Second String in First String Testing"
print
printUsing builtin count: stringcountstring
printUsing occurrencesloop function:
occurrencesloopstring string
printUsing occurrencesrecursion function:
occurrencesrecursionstring string
#
main
grading:
points A function named concatenationloop is implemented that has two string parameters. The function must return the concatenation of the two strings using an appropriate loop. You may use the builtin concatenation operator to concatenate a string and a character. However, you may not use it to concatenate two strings.
point A function named concatenationrecursion is implemented that has two string parameters. The function must return the concatenation of the two strings using recursion. You may use the builtin concatenation operator to concatenate a string and a character. However, you may not use it to concatenate two strings. Do not use any loops in the solution.
points A function named occurrencesloop is implemented that has two string parameters. The function must return the number of times that the second string parameter appears in the first using an appropriate loop. The builtin count function may not be used.
point A function named occurrencesrecursion is implemented that has two string parameters. The function must return the number of times that the second string parameter appears in the first using recursion. Neither the builtin count function nor any loops may be used.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started