STRINGS IN PYTHON
Level 1
Question 1
Write a Python program to calculate the length of a string.
Try YourSelf
View Solution
Video Solution
Question 2
Write a Python program to count the number of characters (character frequency) in a string.
View Solution
Video Solution
Question 3
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.
Try YourSelfView Solution
Video Solution
Question 4
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.
Try YourSelf
View Solution
Video Solution
Level 2
Question 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.
Try YourSelf
View Solution
Video Solution
Question 2
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' instead. If the string length of the given string is less than 3, leave it unchanged
Try YourSelf
View Solution
Video Solution
Question 3
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
Try YourSelf
View Solution
Video Solution
Question 4
Write a Python function that takes a list of words and return the longest word and the length of the longest one.
Try YourSelf
View Solution
Video Solution
Level 3
Question 1
Write a Python program to remove the nth index character from a nonempty string.
Try YourSelf
View Solution
Video Solution
Question 2
Write a Python program to change a given string to a new string where the first and last chars have been exchanged.
View Solution
Video Solution
Question 3
Write a Python program to remove the characters which have odd index values of a given string
Try YourSelf
View Solution
Video Solution
Question 4
Write a Python program to count the occurrences of each word in a given sentence.
Try YourSelf
View Solution
Video Solution
Level 4
Question 1
Write a Python script that takes input from the user and displays that input back in upper and lower cases.
Try YourSelfView Solution
Video Solution
Question 2
Write a Python program to display formatted text (width=50) as output.
Try YourSelf
View Solution
Video Solution
Question 3
Write a Python program to remove existing indentation from all of the lines in a given text.
Try YourSelfView Solution
Video Solution
Question 4
Write a Python program to add a prefix text to all of the lines in a string.
Try YourSelf
View Solution
Video Solution
Level 5
Question 1
Write a Python program to set the indentation of the first line.
Try YourSelf
View Solution
Video Solution
Question 2
Write a Python program to convert a given string into a list of words.
Try YourSelfView Solution
Video Solution
Question 3
Write a Python program to find the maximum occurring character in a given string.
Try YourSelfView Solution
Video Solution
Question 4
Write a Python program to remove duplicate characters of a given string.
Try YourSelfView Solution
Video Solution