insert_sting_middle(‘[[]]<<>>’, ‘Python’) -> [[Python]]
insert_sting_middle(‘{{}}’, ‘PHP’) -> {{PHP}}
Click me to see the sample solution
17. 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). Go to the editor
Sample function and result :
insert_end(‘Python’) -> onononon
insert_end(‘Exercises’) -> eseseses
Click me to see the sample solution
18. 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. Go to the editor
Sample function and result :
first_three(‘ipy’) –> ipy
first_three(‘python’) -> pyt
Click me to see the sample solution
19. Write a Python program to get the last part of a string before a specified character. Go to the
editor
https://www.w3resource.com/python-exercises
https://www.w3resource.com/python
Click me to see the sample solution
20. Write a Python function to reverses a string if it’s length is a multiple of 4. Go to the editor
Click me to see the sample solution
21. 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. Go to the editor
Click me to see the sample solution
22.Write a Python program to sort a string lexicographically. Go to the editor
Click me to see the sample solution
23. Write a Python program to remove a newline in Python. Go to the editor
Click me to see the sample solution
24. Write a Python program to check whether a string starts with specified characters. Go to the
editor
Click me to see the sample solution
25. Write a Python program to create a Caesar encryption. Go to the editor
Note : In cryptography, a Caesar cipher, also known as Caesar’s cipher, the shift cipher, Caesar’s
code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a
type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed