Strings in Python Preeti Arora Class 11 IP Solution || Strings in Python Class 11 Solution || Strings in Python Class 11 IP Solution || Strings in Python Information Practices Solution || Preeti Arora Strings in Python Solution || Strings in Python Class 11 IP || Strings in Python Solution

 

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


Q1. What is a String in Python?


Q2. Define String Slicing.


Q3. How does operator behave on strings?


Q4. Explain function split () with example.


Q5. How many times is the word 'HELLO' printed in the following statement?

s = "python rocks"
for ch in s:
    print("Hello")



Q6. Write the output of the following:

>>> x = "hello"
>>>print (x [1:-2])




Q7. Write the output of the following:
(a)
string = "Hello Madam, I love Tutorials"
substring = "Madam"
if string.find(substring) != -1:
    print ("Python found the substring!")
else:
    print ("Python did NOT find the substring!")
(b)
s = "Strings in Python"
print (s.capitalize())
print (s.title())
s6 = s.replace("in", "data type")
print (s6)




Q8. Find the output of the following:

word = 'work hard'
result = word.find('work')
print("Substring, 'work', found at index:", result )
result = word.find('har')
print("Substring, 'har, found at index:", result)
if (word.find('pawan') != -1):
    print("Contains given substring")
else:
    print("Doesn't contain given substring")




Q9. Write the Python statement and the output of the following:

(a) Find the third occurrence of 'e' in 'sequence'.
(b) Change the case of each letter in the string 'FuNTioN'.
(c) Whether exists in the string 'School' or not.




Q10. Consider the string str1 = "Global Warming".
Write statements in Python to implement the following:

(a) To display the last four characters.
(b) To replace all the occurrences of letter 'a' in the string with "*".




Q11. Input the string 'My School'. Write a script to partition the string at the occurrence of letter ‘h’.


Q12. Write a script to partition the string 'INSTITUTE' at the occurrence of letter ‘T’.


Q13. What is the function of split() method?


Q14. What will be the output of the following programming code?

str = "My Python Programming"
print (str[-5:-1])
print (str[1:5])
print (str[:-4])
print (str[0:])
print (str[:13-4])
print (str[:3])




Q15. Write a program to count the number of each vowel in a given string.


Q16. Write a program that reads a line, counts how many times the word 'is' appears in the line and then displays the count.


Q17. Write a program to remove ‘i’ (if any) from a string.


Q18. Why are strings called immutable?

Post a Comment

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

Previous Post Next Post