Pycent.com

Python B A S I C S Study the code and Answer the questions

Creator:TechBrainWaveAi.com
Session Number:
Attempt Number:

def concatenate_strings(str1, str2):
    """Concatenate two strings and return the result."""
    return str1 + " " + str2
def reverse_string(s):
    """Return the reverse of the input string."""
    return s[::-1]
      
def count_vowels(s):
    """Count the number of vowels in the string."""
    vowels = 'aeiouAEIOU'
    return sum(1 for char in s if char in vowels)
      
def main():
    first_string = input("Enter the first string: ")
    second_string = input("Enter the second string: ")
      
    concatenated = concatenate_strings(first_string, second_string)
    print("Concatenated String:", concatenated)
      
    reversed_string = reverse_string(concatenated)
    print("Reversed String:", reversed_string)
      
    try:

        vowel_count = count_vowels(concatenated)
        print("Number of vowels in concatenated string:", vowel_count)
    except Exception as e:
        print("Error while counting vowels:", e)
      
if __name__ == "__main__":
    main()
      
      
        
Merit: 0