To Know Python Version?

import sys
print(sys.version)

To count Number of Vowels?

def count_vowels(s):
    """
    Function to count the number of vowels in the input string.
    
    Parameters:
    s (str): The input string to check for vowels.
    
    Returns:
    int: The count of vowels in the input string.
    """
    count = 0
    for char in s.lower():
        if char in ('a', 'e', 'i', 'o', 'u'):
            count += 1  # Fixed increment
    return count

print(count_vowels(input("Enter a string: ")))  # Print the result
def count_vowels(s):
    return sum(1 for char in s.lower() if char in 'aeiou')
s=input("Enter a string: ")
print(count_vowels(s))

 char in ‘aeiou’ also works and char in (‘a’,’e’,’i’,’o’,’u’)

Yes, both forms work in Python, but there is a difference:

  • 'aeiou' is a string.
    char in 'aeiou' checks if char is one of the characters 'a''e''i''o', or 'u'.
  • ('a','e','i','o','u') is a tuple of single-character strings.
    char in ('a','e','i','o','u') also checks if char is one of those vowels.

Both are correct and equivalent for this use case.
Using 'aeiou' is more concise and common for single characters.