Page 380 - Computer Science V2.0 Class 11
P. 380
Case-based Questions
1. Every email address consists of three parts—unique id, ‘@’, and domain name. For example, in the email-id
rknararayan@bbpspp.co.in, rknararayan is the unique id, and bbpspp.co.in is the domain name.
Write a Python program that accepts a list of email ids and counts the number of email ids having the domain gmail.com
2. Rashmi knows that a number can be converted to string using the function str() and a string can be converted into an
integer using int(). She wants to work with strings (comprising alphabets, digits, and special characters ) as user input.
She wants to see the number obtained on ignoring the non-digit characters. Once she gets the number, she wants to square
it up. Help Rashmi in writing a Python program that achieves this.
NCERT Exercise Solutions
1. Consider the following string mySubject:
mySubject = "Computer Science"
What will be the output of the following string operations :
i. print(mySubject[0:len(mySubject)])
ii. print(mySubject[-7:-1])
iii. print(mySubject[::2])
iv. print(mySubject[len(mySubject)-1])
v. print(2*mySubject)
vi. print(mySubject[::-2])
vii. print(mySubject[:3] + mySubject[3:])
viii. print(mySubject.swapcase())
ix. print(mySubject.startswith('Comp'))
x. print(mySubject.isalpha())
Ans. i. Computer Science
ii. Scienc
iii. Cmue cec
iv. e
v. Computer ScienceComputer Science
vi. eniSrtpo
vii. Computer Science
viii. cOMPUTER sCIENCE
ix. True
x. False
2. Consider the following string myAddress:
myAddress = "WZ-1,New Ganga Nagar,New Delhi"
What will be the output of following string operations :
i. print(myAddress.lower())
ii. print(myAddress.upper())
iii. print(myAddress.count('New'))
iv. print(myAddress.find('New'))
v. print(myAddress.rfind('New'))
vi. print(myAddress.split(','))
vii. print(myAddress.split(' '))
viii. print(myAddress.replace('New','Old'))
ix. print(myAddress.partition(','))
x. print(myAddress.index('Agra'))
Ans: i. wz-1,new ganga nagar,new delhi
ii. WZ-1,NEW GANGA NAGAR,NEW DELHI
iii. 2
iv. 5
366 Touchpad Computer Science (Ver. 2.0)-XI

