Professional Documents
Culture Documents
CS Practical File Iii 1
CS Practical File Iii 1
CODES:-
for i in str1:
if(i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'
or i == 'A' or i == 'E' or i == 'I' or i == 'O' or i == 'U'):
vowels = vowels + 1
else:
consonants = consonants + 1
RESULTS:-
Please Enter Your Own String : Python Tutorial
Total Number of Vowels in this String =5
Total Number of Consonants in this String =10
2.Write python program to check whether a string is palindrome or not?
CODES:
# Python Program to Check a Given String is Palindrome or Not
RESULTS:
Please enter your own String : wow
This is a Palindrome String
j="-"
print (j.join(ns))
RESULTS:
Please Enter Your Own String : ATUL IS FOODIE
A-T-U-L-I-S-F-O-O-D-I-E
>
5.
CODE:
line=input("Enter a line:")
w=line.split()
count=0
print(w)
for i in w:
count=count+1
lower_count=0
upper_count=0
digit_count=0
alpha_count=0
for i in line:
if i.islower():
lower_count=lower_count+1
elif i.isupper():
upper_count=upper_count+1
elif i.isdigit():
digit_count=digit_count+1
for i in line:
if i.isalpha():
alpha_count=alpha_count+1
print("Number of uppercase:", upper_count)
print("Number of lowercase:",lower_count)
print("Number of alphabet:",alpha_count)
print("Number of digitcount:",digit_count)
print("Number of word:",count)
RESULTS:
Enter a line:Atul is good boy 8
['Atul', 'is', 'good', 'boy', '8']
Number of uppercase: 1
Number of lowercase: 12
Number of alphabet: 13
Number of digitcount: 1
Number of word: 5
>
RESULTS: