Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

CHANDIGARH UNIVERSITY PYTHON PROGRAMMING LAB

CSP-285

PROGRAM USING STARTSWITH AND ENDSWITH:

s1='Crash landing on You'


print(s1.startswith('Crash'))
print(s1.startswith('landing',6,14))
print(s1.startswith('on',14,15))
print(s1.endswith('You'))
print(s1.endswith('on',15,18))
OUTPUT:
PROGRAM OF STRIPPING UNWANTED CHARACTER:
s2='\nThe subtle art of not giving a damn \n \f'
print(s2.lstrip())
print(s2.lstrip('\nThe'))
print(s2.rstrip())
s3='Itaewon class'
print(s3.rstrip('lass'))
s4=' RiJeongHyuk '
print(s4.strip())

PROGRAM USING PADDING FUNCTION:


s5='it is indeed'
print(s5.center(24))
print(s5.center(24,'*'))
print(s5.ljust(24,'#'))
print(s5.rjust(24))
print(s5.zfill(24))
PROGRAM USING FORMATTING FUNCTION:
s6='Hyunbin {0} my all ltime favourite {1} actor'.format('is','SK')
print(s6)
s7='Hyunbin is my %s and he is %d years old'%('bias',37)
print(s7)
PROGRAM USING IMMUTABLE STRING:
s8='Crash landing on You'
print(s8.replace('You','Me'))
s8='Crash'+s8[0:]
print(s8)

s1='Ri Jeong Hyeok12'


count=0
for i in range(len(s1)):

JYOTIKA OINAM 1
18BCS1978
CHANDIGARH UNIVERSITY PYTHON PROGRAMMING LAB
CSP-285

if(s1[i]!=' '):
count=count+1;
print("The number of character in the given string is ",count)
print()
s1='Ri Jeong Hyeok'
s2=input("Enter your string:")
if(s1==s2):
print("The two string are equal")
else:
print("The two string are not equal")

JYOTIKA OINAM 1
18BCS1978

You might also like