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.
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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Answer wyickly
Expert Solution
Step 1
chr function returns the character corresponding to a Unicode code integer. Thus, the input to chr function must be the Unicode for the lowercase characters.
- The Unicode for the lowercase characters is 32 higher than the ASCII value for its uppercase version.
- Thus, add 32 to the ord(ch) of the Uppercase letter and give it as input to the chr function.
Therefore, the blank can be filled as follows:
new_ch = chr(ord(ch) + 32)
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education