1) Write A Python Program To Calculate The Length of A String

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

ASSIGNMENT

1) Write a Python program to calculate the length of a string.


2) Write a Python program to check whether a string starts with specified
characters.
3) Write a Python program to add a prefix text to all of the lines in a string.
4) Write a Python program to sort a string lexicographically(smallest string)
5) Write a Python program to replace a string with another string. Do not use
the replace ( ).
6) Write a Python program to count the number of digits, upper case
characters, lower case characters, words, lines and special characters in a
given string.
7) Write a Python program to read a name and then display it in abbreviated
form like Ramanujan Computing Centre should be displayed as R. C.
Centre.
8) Write a Python program to remove the characters which have odd index
values of a given string. Write a Python program to insert a string in the
middle of a string.
9) Write a Python program to extract the first ‘n’ characters of a string.
10) Write a Python program to delete the first and last characters of a
string.
11) Write a Python program to get a single string from two given strings,
separated by a space and swap the first two characters of each string.

Sample String: 'abc', 'xyz' Expected Result: 'xyc abz'.


12) Write a Python program to get a string from a given string where all
occurrences of its first char have been changed to '$', except the first char
itself.

Sample String: 'restart' Expected Result: 'resta$t'.


13) Write a Python program to convert a string in a list.
14) Write a Python program to find the first non-repeating character in
given string.
15) Write a Python program to find smallest and largest word in a given
string.

You might also like