Implement your own version of Python string methods The provided file string_functions.py defines several string functions, but does not include the code for them. Add code to implement functions that are equivalent in behavior to the corresponding built-in Python string function. Every function MUST return a value. Use loops to implement your functions. You cannot use built-in string methods, string functions, or string-operators to implement your functions. Each function is worth a maximum of 10 points. 1. cal10_upper: Takes a string as a parameter and returns it as a string in all uppercase. Hint: Use the ord () function to get the ASCII value of a character. For example, ord ('a') returns the integer 97. You will also need to use the chr (value) function that returns a string of one character whose ASCII code is the integer value. For example, chr (97) returns the string 'a'. You cannot use the built-in string function upper () for this. 2. cal10_lstrip: Takes a string as a parameter and returns the same string with the whitespace stripped out from the left side of the string.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ
icon
Related questions
Question
Objectives
Practice defining functions with parameters. Practice manipulating strings.
Implement your own version of Python string methods
The provided file string_functions.py defines several string functions, but does not include the
code for them. Add code to implement functions that are equivalent in behavior to the
corresponding built-in Python string function. Every function MUST return a value.
Use loops to implement your functions. You cannot use built-in string methods, string
functions, or string-operators to implement your functions. Each function is worth a maximum
of 10 points.
1. cs110_upper: Takes a string as a parameter and returns it as a string in all uppercase.
Hint: Use the ord () function to get the ASCI value of a character. For example, ord ('a')
returns the integer 97. You will also need to use the chr (value) function that returns a string
of one character whose ASCII code is the integer valus. For example, chr (97) returns the
string 'a'. You cannot use the built-in string function upper () for this.
2. cs110_lstrip: Takes a string as a parameter and returns the same string with the
whitespace stripped out from the left side of the string.
3. cs110_replace: Takes a string and two characters (charl and char2) as parameters and
returns a string with charl replaced by char2 in the string.
4. cs110_in: Takes a long string and a short string as parameters and returns True if the short
string is contained in the long string, and False if it is not.
5. cs110_title: Takes a string and returms a string with the first character capitalized for
every word. The rest of the characters are in lower case. For example, if the input to the function
is "I like Python a lot", the function should return a string that looks like "I Like Python A Lot".
Note: The point of this lab is for you to use loop: to reimplement the string functions. You may
not use Python's built-in string methods or operators to implement yours – for example, in,
. upper (), .isUpper (), .strip (), .split (). You may use these Python functions:
len (), ord (), str (). Ifyou are not sure whether you can use a specific function or method,
ask in Piazza.
Transcribed Image Text:Objectives Practice defining functions with parameters. Practice manipulating strings. Implement your own version of Python string methods The provided file string_functions.py defines several string functions, but does not include the code for them. Add code to implement functions that are equivalent in behavior to the corresponding built-in Python string function. Every function MUST return a value. Use loops to implement your functions. You cannot use built-in string methods, string functions, or string-operators to implement your functions. Each function is worth a maximum of 10 points. 1. cs110_upper: Takes a string as a parameter and returns it as a string in all uppercase. Hint: Use the ord () function to get the ASCI value of a character. For example, ord ('a') returns the integer 97. You will also need to use the chr (value) function that returns a string of one character whose ASCII code is the integer valus. For example, chr (97) returns the string 'a'. You cannot use the built-in string function upper () for this. 2. cs110_lstrip: Takes a string as a parameter and returns the same string with the whitespace stripped out from the left side of the string. 3. cs110_replace: Takes a string and two characters (charl and char2) as parameters and returns a string with charl replaced by char2 in the string. 4. cs110_in: Takes a long string and a short string as parameters and returns True if the short string is contained in the long string, and False if it is not. 5. cs110_title: Takes a string and returms a string with the first character capitalized for every word. The rest of the characters are in lower case. For example, if the input to the function is "I like Python a lot", the function should return a string that looks like "I Like Python A Lot". Note: The point of this lab is for you to use loop: to reimplement the string functions. You may not use Python's built-in string methods or operators to implement yours – for example, in, . upper (), .isUpper (), .strip (), .split (). You may use these Python functions: len (), ord (), str (). Ifyou are not sure whether you can use a specific function or method, ask in Piazza.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY