Assignment 6 - Programs Using Strings
Assignment 6 - Programs Using Strings
Faculty: Dr. V. S. Felix Enigo, Dr. M. Saritha, Dr. S. M. Dhannya, Dr. Anusha Narasimhan, Dr.
A. Vijayalakshmi, Dr. S. Uma Maheswari, Dr. N. Kalaichelvi, Dr. M. Mohamed Iqbal and Ms.
Krithikha Sanju S
Learning Outcome:
● You will be able to apply computational thinking to devise solutions using Strings.
● You code Python programs by defining the functions to handle strings.
Best Practices: Naming conventions to be followed.
Assignment:
Solve the following problem using Python (CO3, K3, 1.3.1, 1.4.1, 13.3.1)
A Speech Processing application requires to validate the file name for its internal
purpose. The specification for validating the filename is given below.
Naming convention to be verified:
1. The first three characters in the filename specify the speaker id.
2. The file name should begin with ‘s’ or ‘S’, which refers to the speaker.
3. Followed by two digits in the range 02-55, to uniquely identify a speaker.
4. The first three characters are followed by either of these 2 patterns, _p_ or _l_
5. It is followed by a string of maximum length 6 which can be fully alphabets or a
combination of alphabets and numbers (but should not exceed 6 characters). The
starting character should be an alphabet.
6. Then it should follow .wav
Example of valid string: “s02_p_alpha.wav", “S24_l_test01.wav”
7. Whenever the filename does not match the given specification, display invalid and give
a specific error message. For example, if the number of characters exceeds 6 then, display
“Please enter a filename with 6 characters”.
8. Display the number of characters present in the file name.
Additional Problems (Using in-built function and without in-built function)
1. Count the words in a given line.
2. Find the longest word in a given sentence.
3. Find all the words that end with ‘ing’.
4. Convert the given text to lowercase and uppercase.
5. Find the number of occurrences of the substring “the” in a given sentence.
Sample Text: "The more the merrier, but the more the noise, the harder the conversations, and
the more the chaos fills the room."
6. Find whether the given text is a Palindrome or not.