0% found this document useful (0 votes)
21 views3 pages

String Manipulation Programs in Python

The document describes three Python programs: the first counts uppercase and lowercase letters in a string, the second counts vowels, and the third reverses a string. Each program includes code snippets and sample outputs demonstrating their functionality. The examples illustrate how user input is processed to produce the desired results.

Uploaded by

sumantaya1980
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

String Manipulation Programs in Python

The document describes three Python programs: the first counts uppercase and lowercase letters in a string, the second counts vowels, and the third reverses a string. Each program includes code snippets and sample outputs demonstrating their functionality. The examples illustrate how user input is processed to produce the desired results.

Uploaded by

sumantaya1980
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program 1: Count Uppercase and Lowercase Letters

Program Code:
str1 = input("Enter the string: ")
uppercase = 0
lowercase = 0
i=0
while i < len(str1):
if str1[i].isupper():
uppercase += 1
if str1[i].islower():
lowercase += 1
i += 1
print("No. of uppercase letters in the string =", uppercase)
print("No. of lowercase letters in the string =", lowercase)

Output:
Enter the string: INDIA is My Motherland
No. of uppercase letters in the string = 7
No. of lowercase letters in the string = 12
Program 2: Count Vowels in a String

Program Code:
s = input("Enter a string: ")
count = 0
for ch in s:
if [Link]() in 'aeiou':
count += 1
print("Number of vowels in the string =", count)

Output:
Enter a string: Education
Number of vowels in the string = 5
Program 3: Reverse a String

Program Code:
s = input("Enter a string: ")
rev = ""
for i in s:
rev = i + rev
print("Reversed string =", rev)

Output:
Enter a string: Python
Reversed string = nohtyP

You might also like