Vowel Check - Conditional - Python Programming Exercise

This Python program prompts the user to input a symbol and categorizes it as a vowel (if it’s a lowercase vowel), a digit, or any other symbol. The program uses an if statement to check the conditions and classify the input accordingly. It first checks if the symbol is one of the vowels "a", "e", "i", "o", or "u" (in lowercase), then checks if it's a digit using Python's isdigit() method. If neither condition is met, it classifies the symbol as any other character. This simple exercise provides a clear example of conditional statements in Python, allowing users to understand how to make decisions based on user input. By checking different conditions using if statements, this program helps users grasp the concept of string manipulation and type checking, which are fundamental in Python programming. This task also encourages practice in working with characters and strings in a practical context.

 Category

Python Data Types

 Exercise

Vowel Check - Conditional

 Objective

Develop a Python program to prompt the user for a symbol and respond if it's a vowel (in lowercase), a digit, or any other symbol, using "if".

 Example Python Exercise

 Copy Python Code
# Prompt the user for a symbol
symbol = input("Enter a symbol: ")

# Check if the symbol is a vowel (in lowercase)
if symbol in 'aeiou':
    print("It's a vowel.")
# Check if the symbol is a digit
elif symbol.isdigit():
    print("It's a digit.")
# If it's neither a vowel nor a digit, it's another symbol
else:
    print("It's another symbol.")

 Output

Case 1:
Enter a symbol: a
It's a vowel.

Case 2:
Enter a symbol: 5
It's a digit.

Case 3:
Enter a symbol: #
It's another symbol.

 Share this Python Exercise

 More Python Programming Exercises of Python Data Types

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Northeast Triangle

    This Python program prompts the user to enter a width and then displays a triangle pattern where the number of stars decreases with each row, and underscores (...

  •  Prime Divisors

    This Python program prompts the user to enter a number and then displays that number as a product of its prime factors. The program uses a factorization approa...

  •  Conditional Symbols

    This Python program prompts the user to enter a symbol and determines whether it is an uppercase vowel, a lowercase vowel, a digit, or any other ...

  •  Character Loop

    This Python program uses a "for" loop to print the uppercase letters from "B" to "N". By utilizing Python's range() function and specifying the A...

  •  Double Precision Pi Approximation

    This Python program calculates an approximation for PI using the series expression: pi/4 = 1/1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 ... The program allows t...

  •  Perimeter and Area

    This Python program calculates the perimeter, area, and diagonal of a rectangle based on its width and height. The program prompts ...