Given a variable s that contains a non-empty string, write some statements that use a while loop to assign the number of lower-case vowels ("a","e","i","o","u") in the string to a variable vowel_count.

Respuesta :

Answer:

Following is the program in the python language

s="Hellooo" #string initialization

k=0 # variable declaration

vowel_count=0 #variable declaration

while k<len(s): #iterating the loop

   c1=s[k] #store in the c1 variable  

   if c1=='a' or c1=='e' or c1=='i' or c1=='o' or c1=='u': #check the condition

       vowel_count= vowel_count +1; # increment the variable vowel_count  

   k = k+1

print(vowel_count) #display

Output:

4

Explanation:

Following is the description of program

  • Create the string "s" and store some characters on them.
  • Declared the variable "k" and initialized 0 on them .
  • Declared the variable "vowel-count" and initialized 0 on them .
  • Iterating the while loop ,inside that loop we shifted the string "s" into the " c1" variable and checking the condition in the if block by using or operator if the condition is true then it increment the "vowel_count"  variable by 1 .
  • Finally outside the loop we print the value of "vowel_count".