The function below is supposed to replicate the lower() string method (that is, it converts all uppercase letters to lowercase, and doesn't change any other characters). def lower (word): out = ' for ch in word: if ord('A') <= ord (ch) <= ord ('Z'): new_ch = chr(__________ chr(. out += new_ch else: out += ch return out Fill in the blank such that the function works as intended. Hint: The ascii value for a lowercase letter is always 32 higher than the ascii value for its uppercase version. For example, ord('A') is 65, and ord('a') is 97.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

Answer wyickly

The function below is supposed to replicate the lower() string method (that is, it converts all
uppercase letters to lowercase, and doesn't change any other characters).
def lower (word):
out =
for ch in word:
II
if ord('A') <= ord (ch) <= ord ('Z'):
new_ch = chr(_
out += new_ch
else:
out += ch
return out
Fill in the blank such that the function works as intended.
Hint: The ascii value for a lowercase letter is always 32 higher than the ascii value for its
uppercase version. For example, ord('A') is 65, and ord('a') is 97.
Transcribed Image Text:The function below is supposed to replicate the lower() string method (that is, it converts all uppercase letters to lowercase, and doesn't change any other characters). def lower (word): out = for ch in word: II if ord('A') <= ord (ch) <= ord ('Z'): new_ch = chr(_ out += new_ch else: out += ch return out Fill in the blank such that the function works as intended. Hint: The ascii value for a lowercase letter is always 32 higher than the ascii value for its uppercase version. For example, ord('A') is 65, and ord('a') is 97.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT