[go: up one dir, main page]

0% found this document useful (0 votes)
6 views1 page

7 August Python String Worksheet2

Uploaded by

gauraansh984
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)
6 views1 page

7 August Python String Worksheet2

Uploaded by

gauraansh984
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/ 1

THE JAIN INTERNATIONAL SCHOOL, KANPUR

Class:XI Subject:CS Worksheet 2- Strings in Python Date:07/08/2025


---------------------------------------------------------------------------------------------------------------------------------
Q1. What is a string in Python? How is it different from a character data type in other languages?
Q2. Explain the concept of string immutability with an example.
Q3. How can you access individual characters and substrings in a Python string?
Q4. What is string slicing? Give two examples.
Q5. Differentiate between find() and index() string methods.
Q6. How does the split() method work in Python? Give an example.
Q7. What is the role of the join() method in strings? Illustrate with an example.
Q8. Explain any three commonly used string methods in Python.
Q9. What is the purpose of the strip(), lstrip() and rstrip() methods?
Q10. How can you test the properties of strings using isalpha(), isdigit(), and isspace()?
Q11. What is the output of s = "hello"; s.upper()? Explain why.
Q12. Write a Python statement to convert the string "Python Programming" into lowercase and then
replace "Python" with "Java".
Q13. What is the difference between == and is when comparing strings?
Q14. How can you reverse a string in Python using slicing?
Q15. Explain the role of escape sequences in strings with any two examples.
Q16. How does the replace() method work in Python strings? Show with a sample.
Q17. What are raw strings in Python? Why are they useful?
Q18. Describe the concept of string formatting using f-strings.
Q19. What is the output of the following and why?
"abc" * 3
Q20. Write a Python function that takes a string and returns the number of vowels in it.
Q21. Explain how negative indexing works in Python strings. Provide an example.
Q22. What is the difference between capitalize() and title() string methods?
Q23. Explain the working of the count() method in strings.
Q24. How does string concatenation work in Python? Illustrate with an example.
Q25. How can you check whether a given string is a palindrome using Python?
Q26. Describe any two differences between mutable and immutable data types with reference to strings.
Q27. Write a Python expression to extract "thon" from the string "Pythonic".
Q28. What is returned by the endswith() method? Give an example.
Q29. How can you convert a string containing comma-separated values into a list?
Q30. Explain the use of the format() method for string formatting in Python.
Q31. What are multiline strings? How can they be created in Python?
Q32. How does rfind() differ from find() in strings?
Q33. What is the purpose of the isalnum() method in string manipulation?
Q34. How would you extract every alternate character from a string in Python?
Q35. How can we remove a specific character from a string without using replace()?
Q36. Write a Python expression to check if the word "data" exists in a string.
Q37. What will the following return? Explain.
s = "data"; print(s * 2)
Q38. What are the escape sequences \n, \t, and \\ used for?
Q39. How can you check whether a string is in uppercase or not?
Q40. Can strings be compared using relational operators in Python? Justify your answer.
Q41. Explain the difference between "hello".isalpha() and "hello123".isalnum().
Q42. What is the role of triple quotes (''' or """) in Python strings?
Q43. How can you center a string using the center() method?
Q44. Write a Python statement to replace all spaces in a string with hyphens.
Q45. Explain the difference between the following two statements:
print("a" > "b")
print("A" > "a")

You might also like