Strings
Strings
2. 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.
Sample String : 'codemania'
Expected Result : 'coia'
Sample String : 'co'
Expected Result : 'coco'
Sample String : ' c'
Expected Result : Empty String
3. 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'
4. Write a Python program to remove the nth index character from a nonempty string.
5. Write a Python script that takes input from the user and displays that input back in
upper and lower cases.
8. Write a Python program to print the square and cube symbol in the area of a
rectangle and volume of a cylinder.
Sample output:
The area of the rectangle is 1256.66cm2
The volume of the cylinder is 1254.725cm3
12. Write a Python program to capitalize first and last letters of each word of a given
string.
13. Write a Python program to create a string from two given strings using
concatenation.
14. Write a Python program to count Uppercase, Lowercase, special character and
numeric values in a given string.