0% found this document useful (0 votes)
33 views2 pages

Strings 2

Uploaded by

Divyesh .R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Strings 2

Uploaded by

Divyesh .R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ACTIVITY : 2 ACTIVITY : 3

Q1. Predict the output :


>>> ‘come’ in ‘welcome’
>>> ‘Come’ not in ‘Welcome’
>>> ‘Tiger’ == ‘tiger’
>>> ‘Amar’ > ‘Aman’

Q2.
>>>Str1=”Welcome to Python Programming’
>>>Str1[2:6]
>>>Str1[-2:-10:-1]
>>>Str1[6:15:2]
>>>Str1[4:9]+Str1[::-3]
Q3. Q3.
a = str("572") Strings are mutable [ True / False ]
b = "Python" * 4 Q4.
print(a,b) s=”Amarthya Sen”
a=a+b s[2]=’e’
print(len(a)) print(s)
Is the above code produce output? If yes what
will be the output ? if not , why?
Q4. Q5.
s="python string fun" Write the output of the following :
for i in range(0,len(s)): >>>Mystr=”Knowledge is Power”
if s[i]>='c' and s[i]<='l': >>>Mystr.upper().lower()
print(s[i].lower(),end="") >>>Mystr.lower().count(‘e’)
else: >>>Mystr.isalnum()
print(s[i].upper(),end="") >>>Mystr.isupper()
>>>Mystr.capitalize()
Q5. Q6.
s="Python is fun" >>> s="welcome to python"
while True: >>> s.strip('weon')
if s[0]=='p': >>> s.lstrip('we').capitalize()
s = s[3:] >>> s.rstrip('thon').count('o')
elif s[-1]=='n': >>> s.find('o',7)
s=s[:2] >>> s.join('#')
else: >>> '#'.join(s)
break
print(s)
Q6. Q6. Write a program to input a line of string and
a "Mummy?Papa?Brother?Sister?Uncle" count the number of vowels, consonants, special
print(a.split()) characters.
print(a.split('?',1)
print(a.split('?',10) Q7. Write a program to accept a line of string,
print(a.split('?',-1) display the words which has more than 5 letters, its
print(a.partition('?') length and in reverse.

You might also like