Last active
December 7, 2018 14:04
-
-
Save santoshpy/abfb918e31f43fde21f8a46afa28f66d to your computer and use it in GitHub Desktop.
String exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. | |
Sample String : 'restart' | |
Expected Result : 'resta$t' | |
""" | |
""" | |
2. 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. | |
Sample String : 'abc', 'xyz' | |
Expected Result : 'xyc abz' | |
""" | |
""" | |
3. Write a Python program to remove the nth index character | |
from a nonempty string. | |
Hint: 'string' and 'index' both from user input | |
""" | |
""" | |
4. Write a Python program to change a given string to a new string | |
where the first and last chars have been exchanged. | |
""" | |
""" | |
5. Write a Python program that accepts a comma separated sequence of words | |
as input and prins in list | |
Sample Words : red, white, black, red, green, black | |
Expected Result : [black, green, red, white,red] | |
""" | |
""" | |
6. Write a Python program to create the HTML string with tags around the word(s). | |
Sample input and result : | |
input: 'i' and 'Python' | |
output: '<i>Python</i>' | |
input: 'b', and 'Python Tutorial' | |
output: '<b>Python Tutorial </b>' | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment