Page 526 - Computer Science V2.0 Class 11
P. 526
'''
Objective : To replace spaces in string with '*'
Input Parameter : string
Return Value : string
'''
return string.replace(' ', '*')
def convertToLowercase(string):
'''
Objective : To convert uppercase letters to lowercase
Input Parameter : string
Return Value : string
'''
return string.lower()
def convertToTitleCase(s):
'''
Objective : To convert string to title case
Input Parameter : string
Return Value : string
'''
return string.title()
string = input("Enter a string: ")
while True:
print("\nMenu:")
print("1. Length of the string")
print("2. Number of occurrences of 'm'")
print("3. Number of digits")
print("4. Replace spaces with '*'")
print("5. Convert to lowercase")
print("6. Convert to title case")
print("7. Exit")
choice = input("Enter your choice (1/2/3/4/5/6/7): ")
if choice == '1':
length = stringLength(string)
print(f"Length of the string: {length}")
elif choice == '2':
mCount = mCountOccurrence(string)
512 Touchpad Computer Science (Ver. 2.0)-XI

