Computer Programming using python

posted by .

Assume s is a string of lower case characters.

Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print:

Number of vowels: 5
For problems such as these, do not include raw_input statements or define the variable s in any way. Our automating testing will provide a value of s for you - so the code you submit in the following box should assume s is already defined.

  • Computer Programming using python -

    > vowels = "aeiou"
    > [x for x in "azcbobobegghakl" if x in vowels]
    ['e', 'e', 'i', 'a']
    > len([x for x in "azcbobobegghakl" if x in vowels])
    4

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. computer science /use java language

    write the program that inputs a string representing a binary number(0s and 1s). First, your program should veerify that it is indeed a binary number, that is, the number contains only 0s and 1s . if that is not the case, your program …
  2. Statistics

    I'm looking at my notes and I can't seem to figure how my teacher did this problem. She used her name which has 9 letters, 3 vowels, and 6 consonants. If we were to reach in the bag and grab 3 letters out. By using the probability …
  3. java

    Write the following methods and test them.this need to be execute it in Eclipse IDE for Java Developers 1. printVowels - this method should take a String as a parameter and print all the vowels contained in that String one character …
  4. C++ programming computer

    I'm having some trouble trying to program these problems and putting them into the main function. Please help me by giving some advice or website that offer good information for me. The questions are below here: 1. Write a function …
  5. Computer Science

    Suppose that a String variable str has already been defined and holds some String. In the box provided below, write a statement that changes str to all lower case characters, and then copies the result back to str.
  6. Computer Programming using python

    Assume s is a string of lower case characters. Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print Number of times bob occurs is: 2 For …
  7. Computer Programming using python

    Assume s is a string of lower case characters. Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print Longest substring …
  8. programming

    Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should …
  9. Python programming Language

    Assume S is a string of lower case characters. Write a program that counts up the number of vowels contained in the string S. Valid vowels are 'a', 'e', 'I', 'o', and 'u'. For example, if S='azcbobobegghakl' your program should print: …
  10. programming

    1. Assume there are n-tyres that could be used by car, tricycle and bicycle. Write an algorithm to accept n-tyres and generate all the combinations of cars, tricycle and bicycle that would exhaust the n-tyres. 2. Assume S is a string …

More Similar Questions