Menu Bar

Horizontal Scrollable Menu

ads

Search This Blog

various operation on string using string libraries with algorithm

Q) : Implement python script to perform various operation on string using string libraries

Aim : To perform variable operation on string using string libraries 

Algorithm :

step 1: Start
step 2: initialise upper case letters
          capotal = str.upper()
step 3: Initialise upper case letter 
           small = capital.lower()
step 4: Replace str1 to str2
         str2 = str1.replace("students',"engineer")
step 5: print left and right strips
          left  = str1.strip()
          right = str1.strip()
step 6: print prefixes
          prefix1 = str1.startwith("wel come")
step 7: end

Source Code:
str1 = "wel come to all student"capital = str1.upper()
print(capital)
str2 = "WEL COME TO MITS"lower = str2.lower()
print(str2)
str3 = str2.replace("MITS","madanapalle")
print(str3)
str4 = "This is an example of strip"left = str4.strip()
print(left)
prefix1 = str1.startswith('hellow')
print(prefix1)
prefix2 = str1.startswith('wel')
print(prefix2)
prefix3 = str1.endswith('student')
print(prefix3)

Output:

WEL COME TO ALL STUDENT
WEL COME TO MITS
WEL COME TO madanapalle
This is an example of strip
False
True
True

Process finished with exit code 0

No comments:

ads3