-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem 1.py
More file actions
64 lines (41 loc) · 1.96 KB
/
Copy pathProblem 1.py
File metadata and controls
64 lines (41 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
""" Problem 1: Write a Python Program to calculate the total number of vowels and
count each of individual vowels in the string"""
vowels=['a','e','i','o','u','A','E','I','O','U'] # vowels in upper&lower case
str= "Guvi Geek Network Private Limited" # given string
# To count the total number of vowels in the string:
total_vowels=0 # variable to store total no. of vowels in each iteration
for i in vowels: # outer loop iterate through vowels
for j in str: # inner loop checks vowels in the string
if i==j: # if condition to check the vowels and the 'char' in string is same.
total_vowels=total_vowels+1
print("Total vowels in the String:",total_vowels)
# To count number of "a" or "A" in the given string:
a_count=0
for i in str: # loops through the given string
if i=='a' or i=='A': # condition to check the vowel 'a or A' in the string
a_count+=1
print("Total 'a' in the given String:",a_count) # prints the total number of 'a or A' in the string
# To count number of "e" or "E" in the given string:
e_count=0
for i in str:
if i=='e' or i=='E':
e_count+=1
print("Total 'e' in the given String:",e_count)
# To count number of "i" or "I" in the given string:
i_count=0
for i in str:
if i=='i' or i=='I':
i_count+=1
print("Total 'i' in the given String:",i_count)
# To count number of "o" or "O" in the given string:
o_count=0
for i in str:
if i=='o' or i=='O':
o_count+=1
print("Total 'o' in the given String:",o_count)
# To count number of "u" or "U" in the given string:
u_count=0
for i in str:
if i=='u' or i=='U':
u_count+=1
print("Total 'u' in the given String:",u_count)