You are on page 1of 2

PRACTICAL PROBLEMS BASED ON STRINGS IN PYTHON

1. Write a program to enter your school name and print the school’s
name up to its character times.
2. Write a program to find whether two strings have equal number of
characters or not.
3. Write a program that takes a message as input and prints that
message without vowels character.
4. Write a function to calculate total number of characters, alphabets,
digits and spaces in a string.
5. Write a program to replace every space in a string by a hyphen (-).
6. Write a program to count total number of characters (include
spaces) except vowels in a given string.
7. Write a program to find the number of characters and words in a
given string. Assume that the words are separated by a single
space.
8. Given a string, if its length is at least 3, add 'ing' to its end. Unless
it already ends in 'ing', in which case add 'ly' instead. If the string
length is less than 3, leave it unchanged. Return the resulting
string.
9. Given a string s, return a string where all occurences of its first
char have been changed to '*', except do not change the first char
itself. e.g. 'babble' yields 'ba**le' . Assume that the string is length
1 or more.Hint: s.replace(stra, strb) returns a version of string s
where all instances of stra have been replaced by strb.
10. Write a Python program to count the number of characters
(character frequency) in a string.
11. Write a Python program that takes a string and prints
the length of the longest one.
12. Write a Python program to change a given string to a new
string where the first and last chars have been exchanged.
13. Write a Python function to insert a string in the middle of a
string.
14. Write a Python function to reverses a string if it's length is a
multiple of 4.

You might also like