Strings NCERT Solution || Strings Class 11 Solution || Strings Python Class 11 CS Solution || Strings Computer Science Solution || NCERT Strings Solution || Strings in Python Class 11 CS || Strings in Python Solution


Note :-  Please Click on Question to get Answer of  that Question !!


Exercise


Q1. 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())



Q2. 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'))



Programming Problems



Q1. Write a program to input line(s) of text from the user until enter is pressed. Count the total number of characters in the text (including white spaces), total number of alphabets, total number of digits, total number of special symbols and total number of words in the given text. (Assume that each word is separated by one space).


Q2. Write  a  user  defined function  to  convert  a  string with more than one word into title case string where string  is  passed  as  parameter.  (Title case means that the first letter of each word is capitalised)


Q3. Write a function deleteChar()  which takes two parameters one is a string and other is a character. The function should create a new string after deleting all occurrences of the character from the string and return the new string.


Q4. Input a string having some digits. Write a function to return the sum of digits present in this string.


Q5. Write a function that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post