0% found this document useful (0 votes)
4 views7 pages

String Manipulation Programs in Python

The document contains a comprehensive list of programming tasks (WAPs) related to string manipulation in Python. Each task focuses on a specific operation, such as counting characters, removing duplicates, checking for palindromes, and converting cases. The tasks range from basic string operations to more complex algorithms, providing a wide variety of challenges for learners.

Uploaded by

Vamsi Krishna
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

String Manipulation Programs in Python

The document contains a comprehensive list of programming tasks (WAPs) related to string manipulation in Python. Each task focuses on a specific operation, such as counting characters, removing duplicates, checking for palindromes, and converting cases. The tasks range from basic string operations to more complex algorithms, providing a wide variety of challenges for learners.

Uploaded by

Vamsi Krishna
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WAP to print all the characters in a given string.

WAP to print all the items present in the string between the range from m
to n.

WAP to print the uppercase characters in a given string.

WAP to print the lowercase characters in a given string.

WAP to print the ascii numbers(Digits) characters in a given string.

WAP to print the special characters in a given string.

WAP to Print the vowels in a given string.

WAP to Print the consonants in a given string.

WAP to print the reverse of the characters in a given string.

WAP to print even position values characters in a given string.

WAP to print odd position values characters in a given string.

WAP to count the total Number of characters in a given string.(with


length function)

WAP to count the total Number of characters in a given string.(without


length function)

WAP to count alphabets in a given string.

WAP to count Number of uppercase in a given string.

WAP to count lowercase in a given string.

WAP to count Number of special symbols in a given string.

WAP to count uppercase and lowercase in a given string.

WAP to count Number of ascii numbers in a given string.

WAP to Count Total Number of Words in a String.

WAP to Count Total Number of spaces in a String.

WAP to Count Vowels in a String.

WAP to Count consonants in a String.

WAP to Count Vowels and Consonants in a String.

WAP to count Number of new lines in a given string.

WAP to count Number of lines in a given string.

WAP to count no of alphabets, numbers, and special characters in a given


string.

WAP to Count Total no of words in a first line of the Doc String.


WAP to sum of digits in a given string.

WAP to Print First Occurrence of a Character in a String.

WAP to Print Last Occurrence of a Character in a String.

WAP to Print First not Occurrence of a Character in a String.

WAP to Print last not Occurrence of a Character in a String.

WAP to Remove First Occurrence of a Character in a String.

WAP to Remove Last Occurred Character in a String.

WAP to count the occurrence of a specific character in a given string.

WAP to count the max occurrence of a character in a given string.

WAP to count the min occurrence of a character in a given string.

WAP to count the repeats of a specific character in a given string.

WAP to count the max repeated character in a given string.

WAP to count the min repeated character in a given string.

WAP to replace a specific character into a new character.

WAP to convert lowercase to uppercase in a given string.

WAP to convert uppercase to lowercase in a given string.

WAP to convert uppercase to lowercase in even position characters in a


given string.

WAP to convert uppercase to lowercase in odd position characters in a given


string.

WAP to convert the uppercase letter to lowercase letter and lowercase


letter to uppercase letter,if the character is special symbol replace with
* for the given input string.

WAP to convert title case in a given string.

WAP to convert snake_case in a given string.

WAP to Toggle Characters Case in a String.

WAP to replace vowels into ascii values in a given string.(both with and
with temp variable)

WAP to replace consonants into ascii values in a given string. (both with
and with temp variable)

WAP to replace consonants to ascii values in odd position characters in a


given string.(both with and with temp variable)
WAP to replace vowels to ascii values in even position characters in a
given string.(both with and with temp variable)

WAP to Replace white Spaces with Hyphen in a String.(both with and with
temp variable)

WAP to Remove Odd position Characters in a given String.

WAP to Remove even position Characters in a given String.

WAP to Remove alphabets in a given String.

WAP to Remove ascii numbers in a given String.

WAP to Remove special characters in a given String.

WAP to check if the given string is Palindrome or Not.

WAP to check whether the given string is lowercase or not.

WAP to check whether the given number is string or not.

I/p: ‘hello world 123 haii’


o/p:’eoo123aii’

I/p: ‘hello world 123 haii’


o/p:’eo o 123 aii’

I/p: ‘hello world 123 haii’


o/p:’eo o aii’

I/p: ‘hello world 123 haii’


o/p:’hll world haii’

i/p:’hello world’
o/p:’hll wrld’
o/p:’eoo’

i/p:’12hello3 4world4’
o/p:’hll wrld’
o/p:’eoo’
o/p:’12344’

i/p:’(*12hello3$ $4#world4*)’
o/p:’hllwrld’
o/p:’eoo’
o/p:’12344’
o/p:’(*$ $#*)

i/p: ’(*12hello3$ $4#world4*)’


o/p: ')*#$ $*(,44321,ooe,dlrwllh'

i/p:’(*12hello3$ $4#world4*)’
o/p:’hllwrld,eoo,12344,(*$ $#*)’

i/p: ’(*12hello3$ $4#world4*)’


o/p:’,hllwrld,)*#$ $*(’,eoo,44321’
i/p: ’(*12hello3$ $4#world4*)’
o/p: ')*#$ $*(,44321,ooe,dlrwllh'

i/p: ’(*12hello3$ $4#world4*)’


o/p:’dlrwllh)*#$ $*(ooe44321’

I/p:’HELLOWORLD’
o/p:’h$ll*w*rld’

#I/p:’123HELLO WORLD456’
#o/p:’hllwrld21’

#I/p:’123HELLO WORLD456’
#o/p:’123hEllO wOrld456’

#I/p:’123HELLO WORLD456’
#o/p:’321hEllO wOrld654’

#I/p:’123HELLO WORLD456’
#o/p:’321*E**O *O***654’

#I/p:’123HELLO WORLD456’
#o/p:’123*E**O *O***456’

#I/p:’HELLOWORLD’
#o/p:’h$ll*w*rld’

i/p: ‘abc’
i/p: ‘xyz’

o/p:’axbycz’

i/p: ‘abc’
i/p: ‘xyzw’

o/p:’axbyczw’

i/p: ‘abcd’
i/p: ‘xyz’

o/p:’axbyczd’

i/p: ‘abc’
i/p: ‘xyzwop’

o/p:’axbyczwop’

i/p:’abc123’
o/p:’a1b2c3’

i/p:’abc12’
o/p:’a1b2c’

i/p: ‘abc1234’
o/p: ‘a1b2c34’

i/p: ‘1a2bc34’
o/p:’a1b2c34’
i/p:’abcdnmpoijkl12yzabcd5’
o/p:3

I/P: ‘HAII HELLO’


O/P: ‘HA1I2I3 HE4LLO5’

I/P: ‘HAII HELLO’


O/P: ‘H1AII 2H3EL4L5O’

WAP to print all the string values present inside the list if the length
of the string is odd under the first character starts with a vowel.

Write a program for series


Input:- “a3b2c4” ,
Output: “aaabbcccc”

Write a program for series


Input: “aaabbcccc”
Output:- “a3b2c4”

Write a program frequency of each character in given string when count is


a prime number
input:”aaaaBBBcddddfffff”
Output: (“B3”,”c1”,”f5”)

Write a program to swap neighbor char in string.


Input: “abcdefg”
Output:- “badcfeg”

WAP to split the sentence in a given string.


i/p:’haii how are you venu’
o/p:[‘haii’, ’how’,’are’,’you’,’venu’]

Find out the longest word in the string below.


Sentence =”hello world welcome to python”

sentence=” hello world welcome to python”

Output: ’olleh dlrow emoclew ot nohtyp’

sentence=” python is a programming language” (Using dictionary


comprehension)

Output: {‘python’:1, is:1,’a’:1,’language’:1,’programming:1’}

I/p:'PYTHON SCRIPTING PROGRAMMING LANGUAGE'


o/p:['PYTHON’,’SCRIPTING’, ‘PROGRAMMING’,’ LANGUAGE']

I/p:'PYTHON SCRIPTING PROGRAMMING LANGUAGE'


o/p:['nothyp', 'scripting','gnimmargorp', 'language']

I/p: ‘ABCDEFGIJKABC’
O/p: [‘ABCDEFG’, ‘IJK’, ‘ ABC’]

WAP to check whether two given strings contain the same set of characters
but in different [Link] example, “POT” and “OTP” are having the same
set of characters.
WAPto reverse alternate words of a given string starting with the first
word and the swap first and last char of the remaining words.
For example, if “Java Concept for The Day” is input string then output
should be “avaJ toncepc rof eht yaD”

Find the sum of all numbers present in the string and consider -12 as a
negative number in string.
Ex: saf67as71mha-12v1
o/p: 67 + 71 - 12 + 1 = 127

WAP You are given a string and a number n. Remove the characters which
repeat n times or more consecutively and print the remaining string.
Ex: n=2
Input: Shaanvi
Output: Shnvi

WAP Two strings, and are called anagrams if they contain all the same
characters in the same frequencies. For example, the anagrams of CAT are
CAT, ACT, TAC, TCA, ATC, and CTA.
If and are case-insensitive anagrams, print "Anagrams"; otherwise, print
"Not Anagrams" instead.

Constraints
o Length of both strings in between 1 - 50.
o Strings consist of English alphabetic characters.
o The comparison should NOT be case sensitive.

Sample Input
anagram
margana

Sample Output
Anagrams

WAP to find the longest substring without repeating characters in a given


string.
For example, if “javaconceptoftheday” is the input string, then the
longest substring without repeating or duplicate characters is
“oftheday“.

WAP to convert the given string lower case to upper and upper case to
lower.
For example,
Sample Input:
"WelcOMe to YuPP videO serVicES"
Sample Output:
wElComE TO yUpp VIDEo SERvICes

Write a program to remove the duplicates in a given list.

For example,
Sample Input: [5, 3, 5, 2, 1, 6, 6, 4]
Sample Output: [5, 3, 2, 1, 6, 4]
WAP to reverse words in a given sentence without using any library
method.
Sample Input: Yupp video services
Sample Output: ppuy oediv secivres

Given two words, check if both are formed with the same distinct
characters.
Ex: sairam, sarmi

WAP to Form a New String where the First Character and the Last Character
have been Exchanged

You might also like