0% found this document useful (0 votes)
49 views15 pages

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

The document contains 15 Python programming assignments related to string manipulation and analysis. The assignments involve tasks like calculating string length, checking starting characters, adding prefixes, sorting lexicographically, replacing substrings, counting character types, abbreviating names, removing odd indexed characters, inserting substrings, extracting prefixes, deleting prefix/suffix characters, swapping first two characters of two strings, replacing internal characters, converting to lists, finding non-repeating characters, and finding smallest/largest words.

Uploaded by

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

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

The document contains 15 Python programming assignments related to string manipulation and analysis. The assignments involve tasks like calculating string length, checking starting characters, adding prefixes, sorting lexicographically, replacing substrings, counting character types, abbreviating names, removing odd indexed characters, inserting substrings, extracting prefixes, deleting prefix/suffix characters, swapping first two characters of two strings, replacing internal characters, converting to lists, finding non-repeating characters, and finding smallest/largest words.

Uploaded by

Sarath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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