Select the correct answerThe output of executing string.ascii_letters can also be achieved by:Optionsstring.lettersstring.lowercase_string.uppercasestring.ascii_lowercase+string.ascii_uppercasestring.ascii_lowercase_string.digits
Question
Select the correct answerThe output of executing string.ascii_letters can also be achieved by:Optionsstring.lettersstring.lowercase_string.uppercasestring.ascii_lowercase+string.ascii_uppercasestring.ascii_lowercase_string.digits
Solution
The correct answer is string.ascii_lowercase+string.ascii_uppercase.
This is because string.ascii_letters in Python returns a string of all the ASCII characters that are considered letters, which includes both lowercase and uppercase letters. This can also be achieved by concatenating string.ascii_lowercase (which returns all lowercase letters) and string.ascii_uppercase (which returns all uppercase letters).
The other options are incorrect because:
- string.letters does not exist in Python.
- string.lowercase_string.uppercase does not exist in Python.
- string.ascii_lowercase_string.digits does not exist in Python and it would also include digits, which are not considered letters.
Similar Questions
How can you convert a lowercase character to uppercase manually in a string?
Which method can be used to return a string in upper case letters?
How to convert a string str to lowercase characters?Astr.lower()Bstr.toLower()Cstr.toLowerCase()
Select the correct answerWhat will be the output of the following Python code?print("abc. DEF".capitalize())OptionsAbc. Defabc. defAbc. defABC. DEF
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())
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.