Programming 5
Programming 5
Course:
This Python program performs three key operations on the name "PraiseGod":
1. Substring Extraction
Input Handling: Accepts user input for n and clamps it between 0 and the name's length (9 characters)
2. Vowel Counting
Case Handling: Converts characters to lowercase using char.lower() for uniform comparison
Set Membership: Uses a vowel set {'a','e','i','o','u'} for O(1) lookup efficiency
3. String Reversal
Extended Slicing: Uses [::-1] syntax to create reversed copy
Screenshot.
Key Observations:
The program demonstrates Python's string manipulation capabilities with O(n) time complexity for all operations,
Screenshot.
Reference.
Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press. This book is licensed