perform various operations on string using string libraries in python


perform various operations on string using string libraries. In computer science, in the field of formal language theory, frequent use is made up of a variety of string functions; However, the notation used is different from that used for computer programming, and theoretically some commonly used functions are rarely used when programming. This article defines some of these root words.  
  1. Implement Python Script to perform various operations on string using string libraries.
Aim:  To perform various operations on string using string libraries. Algorithm:    Step1. Start    Step2. Initialize upper case letters capital=str1.upper()    Step3. Initialize lower case letters small=capital.lower()    Step4. Replace str1 to str 2 str2=str1.replace(“students”,”engineers”)    Step5. print left and right strips left=st.lstrip() right=st.rstrip() Step6. print prefixes prefix1=str1.startswith(“Welcome”) Step7. End Program: str1=”Welcome you all students” capital=str1.upper() print(capital) small=capital.lower() print(small) str2=str1.replace(“students”,”engineers”) print(str2) st=”    This is an example of strip   ” left=st.lstrip() print(left) right=st.rstrip() print(right) prefix1=str1.startswith(“Welcome”) print(prefix1) prefix2=str2.startswith(“s”) print(prefix2) prefix3=str2.endswith(“w”) print(prefix3) Output: WELCOME YOU ALL STUDENTS welcome you all students Welcome you all engineers This is an example of strip This is an example of strip True False False   Related Link: perform various operations on string using string libraries. click here for wikipedia

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories