Define a function name_operation(str1), with one string argument. In this function:a. Use upper() function to convert str1 into Uppercase letters, and assign value to variable upperStrb. Use lower() function to convert str1 into Lowercase letters, and assign value to variable lowerStrc. Use title() function to convert the first character of each word in str1 to Uppercase letter, and assign value to variable titleStr
Question
Define a function name_operation(str1), with one string argument. In this function:a. Use upper() function to convert str1 into Uppercase letters, and assign value to variable upperStrb. Use lower() function to convert str1 into Lowercase letters, and assign value to variable lowerStrc. Use title() function to convert the first character of each word in str1 to Uppercase letter, and assign value to variable titleStr
Solution
Sure, here is the Python function as per your requirements:
def name_operation(str1):
# a. Convert str1 into Uppercase letters
upperStr = str1.upper()
# b. Convert str1 into Lowercase letters
lowerStr = str1.lower()
# c. Convert the first character of each word in str1 to Uppercase letter
titleStr = str1.title()
return upperStr, lowerStr, titleStr
This function takes a string as an argument and returns a tuple containing the string in uppercase, lowercase, and title case.
Similar Questions
Write a function that reads your name in lowercase and perform the following operationprints it in uppercaseprints the length of the name
Write a function that reads your name in lowercase and perform the following operationprints it in uppercaseprints the length of the nameSample Inputsanjay kumarSample OutputSANJAY KUMAR12
How can you convert a lowercase character to uppercase manually in a string?
Write a python program to convert all the letters in the string to uppercasestring = "Hello World"print(string.upper())string = "Hello World"print(string.title())string = "Hello World"print(string.capitalize())string = "Hello World"print(string.Upper())
Write a program that converts strings of all uppercase characters into strings of all lowercase and viceversa
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.