1) Write A Python Program To Calculate The Length of A String
This document contains 15 Python programming challenges involving strings. The challenges include calculating string length, checking if a string starts with certain characters, adding a prefix to string lines, sorting strings lexicographically, replacing strings, counting character types in a string, abbreviating names, removing odd index characters, inserting a string in the middle, extracting the first n characters, deleting the first and last characters, swapping the first two characters of two strings, changing repeated characters to $, converting a string to a list, finding the first non-repeating character, and finding the smallest and largest words in a string.
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 ratings0% found this document useful (0 votes)
109 views15 pages
1) Write A Python Program To Calculate The Length of A String
This document contains 15 Python programming challenges involving strings. The challenges include calculating string length, checking if a string starts with certain characters, adding a prefix to string lines, sorting strings lexicographically, replacing strings, counting character types in a string, abbreviating names, removing odd index characters, inserting a string in the middle, extracting the first n characters, deleting the first and last characters, swapping the first two characters of two strings, changing repeated characters to $, converting a string to a list, finding the first non-repeating character, and finding the smallest and largest words in a string.
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
PYTHON 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.
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.
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.