Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Practice problem 1 Write the function countPunct_index that takes a string s and returns the number of punctuation characters in s. In this version, use

image text in transcribed
image text in transcribed
Practice problem 1 Write the function countPunct_index that takes a string s and returns the number of punctuation characters in s. In this version, use a for loop and iteration by index of element. Call the function on my test data. Sample input s= "Let's code!" Expected output 2 Sample input s= 'Does the equation x2+1=0 have real roots?' Expected output 5 Write the function linearSearch that takes a list L of elements of the same type, and a value x of the same type, and returns the (nonnegative) index of this value in the list, or 1 if the value does not exist in the list. That is, you are searching for the value in the list. Use the obvious brute-force strategy of looking for the element in the list by walking through the list from the beginning to the end, looking for the element, and returning the present index as soon as you find it. If the value occurs more than once in the list, return the index of the first occurrence. Sample input L=[30,25,64,30,64,20],x=64 Expected output 2 Sample input L = ['jardin', 'garten', 'hortus', 'garden', 'have', 'puutarha', 'beerta'], x= 'garden' Expected output 3 Sample input L=[30,40,50],x=60 Expected output 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions