Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

CSE ASSIGNMENT - 6

Savya P
22BCE8826

1. Write a python program to replace all occurrences of ‘a’ with


‘b’ in a string. If ‘a’ is not present then print appropriate
message.
Ans:
Input:

Output:
2. Write a python program to remove the nth index character
from a non-empty string.
Ans:
Input:

Output:
3. Write a python program to detect if two strings are anagrams.
Ans:
Input:

Output:
4. Write a python program to form a new string where the first
character and the last character have been exchanged.
Ans:
Input:

Output:
5. Write a python program to get the last part of a string before a
specified character.
Ans:
Input:

Output:
6. Write a python program to count the occurrences of each word
in a given sentence.
Ans:
Input:

Output:
7. Write a python function to insert a string in the middle of a
string.
Ans:
Input:

Output:
8. 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.
Ans:
Input:
Output:

9. Write a python program to add a prefix text to all of the lines in


a string.
Ans:
Input:
Output:

10. Write a python program to convert a given string into a


list of words.
Ans:
Input:
Output:

You might also like