w3resource

Python: Test whether a passed letter is a vowel or not

Python Basic: Exercise-24 with Solution

Write a Python program to test whether a passed letter is a vowel or not.

Pictorial Presentation:

Test whether a passed letter is a vowel or not

Sample Solution :-

Python Code:

def is_vowel(char):
    all_vowels = 'aeiou'
    return char in all_vowels
print(is_vowel('c'))
print(is_vowel('e'))

Sample Output:

False                                                                                                         
True 

Flowchart:

Flowchart: n (non-negative integer) copies of the first 2 characters of a given string.

Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor:

 

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to get the n (non-negative integer) copies of the first 2 characters of a given string. Return the n copies of the whole string if the length is less than 2.
Next: Write a Python program to check whether a specified value is contained in a group of values.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

List comprehension:

>>> m = [x ** 2 for x in range(5)]
>>> m
[0, 1, 4, 9, 16]