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