Python String Exercise With Solutions - String Programs For Practice
Python String Exercise With Solutions - String Programs For Practice
Search this website Home » Python Exercises » Python String Exercise with
Solutions
Posted In
Python String Exercise
with Solutions
Python Python Basics Python
Exercises
Tweet F share in share P Pin Updated on: October 6, 2021 | + 219 Comments
Python Exercises As you know, the stings are widely used to hold
textual data. To perform any programming tasks in
Python Exercises Home
Python, a good understanding of string
Basic Exercise for Beginners
manipulation is necessary.
Input and Output Exercise
Dictionary Exercise
Python String Quiz
Set Exercise
Tuple Exercise
This String Exercise includes the following: –
https://pynative.com/python-string-exercise/ 1/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Table of contents
https://pynative.com/python-string-exercise/ 2/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
World-class AI
https://pynative.com/python-string-exercise/ 3/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
https://pynative.com/python-string-exercise/ 4/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
str1 = "James"
https://pynative.com/python-string-exercise/ 5/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Expected Output:
Jms
+ Show Hint
https://pynative.com/python-string-exercise/ 6/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
https://pynative.com/python-string-exercise/ 7/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
str1 = 'James'
print("Original String is", str1)
Run
https://pynative.com/python-string-exercise/ 8/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
Case 1 Case 2
Output Output
Dip Son
https://pynative.com/python-string-exercise/ 9/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Hint
+ Show Solution
https://pynative.com/python-string-exercise/ 10/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
def get_middle_three_chars(str1):
print("Original String is", str1)
get_middle_three_chars("JhonDipPeta")
get_middle_three_chars("JaSonAy")
Run
Given:
https://pynative.com/python-string-exercise/ 11/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
s1 = "Ault"
s2 = "Kelly"
Expected Output:
AuKellylt
+ Show Hint
+ Show Solution
concatenate x and s2 . x = x + s2
print x
https://pynative.com/python-string-exercise/ 12/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
append_middle("Ault", "Kelly")
Run
https://pynative.com/python-string-exercise/ 13/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
s1 = "America"
s2 = "Japan"
Expected Output:
AJrpan
https://pynative.com/python-string-exercise/ 14/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Hint
+ Show Solution
Given:
str1 = PyNaTive
https://pynative.com/python-string-exercise/ 15/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Expected Output:
yaivePNT
+ Show Hint
+ Show Solution
string
Given:
str1 = "P@#yn26at^&i5ve"
Expected Outcome:
Chars = 8
Digits = 3
Symbol = 4
+ Show hint
https://pynative.com/python-string-exercise/ 17/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
https://pynative.com/python-string-exercise/ 18/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
s1 = "Abc"
s2 = "Xyz"
Expected Output:
AzbycX
+ Show Solution
Given:
https://pynative.com/python-string-exercise/ 19/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
NEWS
All In 1 Place
Case 1: Case 2:
s1 = "Yn" s1 = "Ynf"
s2 = "PYnative" s2 = "PYnative"
+ Show Hint
https://pynative.com/python-string-exercise/ 20/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
Given:
Expected Outcome:
https://pynative.com/python-string-exercise/ 21/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Hint
+ Show Solution
https://pynative.com/python-string-exercise/ 22/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
str1 = "PYnative29@#8496"
Expected Outcome:
+ Show Hint
https://pynative.com/python-string-exercise/ 23/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
Grammarly
Given:
str1 = "Apple"
https://pynative.com/python-string-exercise/ 24/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Expected Outcome:
+ Show Hint
+ Show Solution
Given:
str1 = "PYnative"
Expected Output:
evitanYP
https://pynative.com/python-string-exercise/ 25/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Hint
+ Show Solution
https://pynative.com/python-string-exercise/ 26/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
Expected Output:
+ Show Hint
+ Show Solution
https://pynative.com/python-string-exercise/ 27/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
str1 = Emma-is-a-data-scientist
Expected Output:
Emma
is
https://pynative.com/python-string-exercise/ 28/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
a
data
scientist
+ Show Hint
+ Show Solution
Given:
Expected Output:
https://pynative.com/python-string-exercise/ 29/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Grammarly
+ Show Hint
https://pynative.com/python-string-exercise/ 30/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
Given:
Expected Output:
+ Show Hint
https://pynative.com/python-string-exercise/ 31/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Solution
https://pynative.com/python-string-exercise/ 32/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
Expected Output:
2510
+ Show Hint
+ Show Solution
https://pynative.com/python-string-exercise/ 33/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
Given:
Expected Output:
Emma25
scientist50
https://pynative.com/python-string-exercise/ 34/182
4/4/24, 7:23 PM Python String Exercise with Solutions – String Programs for Practice
+ Show Hint
+ Show Solution
Given:
Expected Output:
https://pynative.com/python-string-exercise/ 35/182