Python Foundation

+91-7982108418            
                     PYTHON STRING IMPORTANT QUESTION

  1. Write a Python program to calculate the length of a string.
  2. Write a Python program to count the number of characters (character frequency) in a  string.
  1. Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.
  1. 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.
  1. 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.
  1. Write a Python program to add ‘ing’ at the end of a given string (length should be at least 3). If the given string already ends with ‘ing’ then add ‘ly’ If the string length of the given string is less than 3, leave it unchanged.
  1. Write a Python program to find the first appearance of the substring ‘not’ and ‘poor’ from a given string, if ‘not’ follows the ‘poor’, replace the whole ‘not’…’poor’ substring with ‘good’. Return the resulting string.
  1. Write a Python function that takes a list of words and returns the length of the longest one.
  1. Write a Python program to remove the nth index character from a nonempty
  1. Write a Python program to change a given string to a new string where the first and last chars have been
  1. Write a Python program to remove the characters which have odd index values of a given string.
  1. Write a Python program to count the occurrences of each word in a given sentence.
  1. Write a Python script that takes input from the user and displays that input back in upper and lower cases.
  1. Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form (alphanumerically).
  1. Write a Python function to create the HTML string with tags around the word(s).
  1. Write a Python function to insert a string in the middle of a string.
  1. Write a Python function to get a string made of 4 copies of the last two characters of a specified string (length must be at least 2).
  1. Write a Python function to get a string made of its first three characters of a specified string. If the length of the string is less than 3 then return the original string.
  1. Write a Python program to get the last part of a string before a specified  character.
  1. Write a Python function to reverses a string if it’s length is a multiple of 4.
  1. Write a Python function to convert a given string to all uppercase if it contains at least 2 uppercase characters in the first 4 characters.
  2. Write a Python program to sort a string lexicographically.
  1. Write a Python program to remove a newline in python.
  1. Write a Python program to check whether a string starts with specified character,
  1. Write a Python program to create a Caesar encryption.
  1. Write a Python program to display formatted text (width=50) as output.
  1. Write a Python program to remove existing indentation from all of the lines in a given text.
  1. Write a Python program to add a prefix text to all of the lines in a string.
  1. Write a Python program to set the indentation of the first line.
  1. Write a Python program to print the following floating numbers upto 2 decimal places.
  1. Write a Python program to print the following floating numbers upto 2 decimal places with a sign.
  1. Write a Python program to print the following floating numbers with no decimal places.
  1. Write a Python program to print the following integers with zeros on the left of specified width.
  1. Write a Python program to print the following integers with ‘*’ on the right of specified width.
  1. Write a Python program to display a number with a comma separator.
  1. Write a Python program to format a number with a percentage.
  1. Write a Python program to display a number in left, right and center aligned of width 10.
  1. Write a Python program to count occurrences of a substring in a string.
  1. Write a Python program to reverse a string.
  1. Write a Python program to reverse words in a string.
  1. Write a Python program to strip a set of characters from a string.
  1. Write a Python program to count repeated characters in a string. Sample string: ‘thequickbrownfoxjumpsoverthelazydog’
  1. Write a Python program to print the square and cube symbol in the area of a rectangle and volume of a cylinder,
  1. Write a Python program to print the index of the character in a string.
  1. Write a Python program to check if a string contains all letters of the alphabets.
  1. Write a Python program to convert a string in a list.
  1. Write a Python program to lowercase first n characters in a string.
  1. Write a Python program to swap comma and dot in a string.
  1. Write a Python program to count and display the vowels of a given text.
  1. Write a Python program to split a string on the last occurrence of the delimiter.
  1. Write a Python program to find the first non-repeating character in given string.
  1. Write a Python program to print all permutations with given repetition number of characters of a given string.
  1. Write a Python program to find the first repeated character in a given string.
  1. Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.
  2. Write a Python program to find the first repeated word in a given string.
  1. Write a Python program to find the second most repeated word in a given string.
  2. Write a Python program to remove spaces from a given string.
  1. Write a Python program to move spaces to the front of a given string.
  1. Write a Python program to find the maximum occurring character in a given string.
  1. Write a Python program to capitalize first and last letters of each word of a given string.
  1. Write a Python program to remove duplicate characters of a given string.
  1. Write a Python program to compute sum of digits of a given string.
  1. Write a Python program to remove leading zeros from an IP address.
  1. Write a Python program to find maximum length of consecutive 0’s in a given binary string.
  1. Write a Python program to find all the common characters in lexicographical order from two given lower case If there are no common letters print “No common characters”.
  1. Write a Python program to make two given strings (lower case, may or may not be of the same length) anagrams removing any characters from any of the strings.
  1. Write a Python program to remove all consecutive duplicates of a given string.
  1. Write a Python program to create two strings from a given string. Create the first string using those character which occurs only once and create the second string which consists of multi-time occurring characters in the said string.
  1. Write a Python program to find the longest common sub-string from two given string.
  1. Write a Python program to create a string from two given strings concatenating uncommon characters of the said strings.
  1. Write a Python program to move all spaces to the front of a given string in single traversal.
  1. Write a Python program to remove all consecutive duplicates from a given string.
  1. Write a Python program to count Uppercase, Lowercase, special character and numeric values in a given string.
  1. Write a Python program to find the minimum window in a given string which will contain all the characters of another given string.
  1. Write a Python program to find smallest window that contains all characters of a given string.
  1. Write a Python program to count number of substrings from a given string of lowercase alphabets with exactly k distinct (given) characters.
  1. Write a Python program to count number of non-empty substrings of a given string.
  1. Write a Python program to count characters at same position in a given string (lower and uppercase characters) as in English alphabets.
  1. Write a Python program to find smallest and largest word in a given string.
  1. Write a Python program to count number of substrings with same first and last characters of a given string.
  1. Write a Python program to find the index of a given string at which a given substring If the substring is not found in the given string return ‘Not found’.
  1. Write a Python program to wrap a given string into a paragraph of given width.
  1. Write a Python program to print four values decimal, octal, hexadecimal (capitalized), binary in a single line of a given integer.
  1. Write a Python program to swap cases of a given string.

Powered by BetterDocs

Contact Us
close slider

error: Content is protected !!