0% found this document useful (0 votes)
3 views

Lab Assignment#3

The document outlines a lab assignment consisting of various string manipulation tasks including string reversal, palindrome check, character frequency counting, and substring search. It also covers advanced string handling techniques such as string compression, anagram checking, and password validation. Additionally, it includes applications of strings like removing punctuation, ASCII conversion, and finding missing characters for pangrams.

Uploaded by

singhsanjay2974
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab Assignment#3

The document outlines a lab assignment consisting of various string manipulation tasks including string reversal, palindrome check, character frequency counting, and substring search. It also covers advanced string handling techniques such as string compression, anagram checking, and password validation. Additionally, it includes applications of strings like removing punctuation, ASCII conversion, and finding missing characters for pangrams.

Uploaded by

singhsanjay2974
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Assignment#3

1. String Reversal: Write a program to reverse a given string without using built-in
functions.
o Input: "hello"
o Output: "olleh"
2. Palindrome Check: Check whether a given string is a palindrome.
o Input: "madam"
o Output: True
3. Character Frequency: Count the frequency of each character in a string.
o Input: "apple"
o Output: {'a': 1, 'p': 2, 'l': 1, 'e': 1}
4. Substring Search: Find whether a given substring exists in a string and its index.
o Input: "hello world", "world"
o Output: True, Index: 6
5. Vowel and Consonant Count: Count the number of vowels and consonants in a
string.
o Input: "engineering"
o Output: Vowels: 5, Consonants: 6

String Manipulation

6. Remove Duplicates: Remove duplicate characters from a string.


o Input: "programming"
o Output: "progamin"
7. String Rotation: Rotate a string n places to the right.
o Input: "python", n=2
o Output: "onpyth"
8. Replace Substring: Replace all occurrences of a substring with another substring.
o Input: "banana", "na", "xy"
o Output: "baxyxy"
9. Word Reversal: Reverse the words in a sentence.
o Input: "hello world"
o Output: "world hello"
10. Duplicate Words: Identify and print all duplicate words in a string.
o Input: "this is is a test test"
o Output: {'is': 2, 'test': 2}

Advanced String Handling

11. String Compression: Compress a string using counts of repeated characters.


o Input: "aaabbcc"
o Output: "a3b2c2"
12. Longest Word: Find the longest word in a sentence.
o Input: "Find the longest word in this sentence"
o Output: "sentence"
13. Anagram Check: Check if two strings are anagrams. An anagram of a string is
another string that contains the same characters, only the order of characters can be
different.
o Input: "listen", "silent"
o Output: True
14. Pangram Check: Check if a string is a pangram (contains every letter of the
alphabet).
o Input: "The quick brown fox jumps over the lazy dog"
o Output: True
15. Case Conversion: Convert a string to uppercase, lowercase, and title case.
o Input: "hello world"
o Output: "HELLO WORLD", "hello world", "Hello World"

Applications of Strings

16. Password Validator: Validate a password based on the following rules:


o Minimum 8 characters, at least one uppercase, one lowercase, one digit, and
one special character.
o Input: "Password@123"
o Output: Valid
17. Remove Punctuation: Remove all punctuation from a string.
o Input: "Hello, world! How's it going?"
o Output: "Hello world Hows it going"
18. ASCII Conversion: Convert each character in a string to its ASCII value and vice
versa.
o Input: "ABC"
o Output: [65, 66, 67]
o Input: [65, 66, 67]
o Output: "ABC"
19. Word Frequency: Count the frequency of each word in a sentence.
o Input: "this is a test this is only a test"
o Output: {'this': 2, 'is': 2, 'a': 2, 'test': 2, 'only': 1}
20. Find Missing Characters: Given a string, find all characters missing to make it a
pangram.
o Input: "The quick brown fox"
o Output: {'a', 'd', 'g', 'j', 'l', 'p', 'v', 'y', 'z'}

You might also like