google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 strings in python mcq with answers | strings in python class 11 mcq | class 11 computer chapter 8 mcq - 2nd puc computer science

strings in python mcq with answers | strings in python class 11 mcq | class 11 computer chapter 8 mcq

strings in python mcq with answers,strings in python mcq,string slicing in python mcq,strings in python class 11 mcq,string in python mcq questions,class 11 string manipulation mcq,strings class 11 mcq,strings mcq in python,strings mcqs,string mcq in python class 11.class 11 computer chapter 8 mcq,mcqs on string in python,string mcq in python,mcq on strings in python class 11,Mcq on strings in python class 11 with answers,Mcq on strings in python class 11 with answers pdf,Mcq on strings in python class 11 pdf,Mcq on strings in python class 11 pdf download

1. What is the output of `str1[::-1]` if `str1 = 'Hello World!'`?





ANSWER= C) `!dlroW olleH`

2. What is the result of `str1[1:5]` if `str1 = 'Hello World!'`?





ANSWER= B) `ello`

3. Which of the following methods returns the string with the first letter of every word in uppercase and the rest in lowercase?





ANSWER= C) `title()`

4. Which function would you use to find the length of a string `str1`?





ANSWER= A) `len()`

5. In Python, what will be the output of `str1[6:]` if `str1 = 'Hello World!'`?





ANSWER= C) `World!`

6. What does the slice operation `str1[n:m:k]` do?





ANSWER= A) Extracts every k-th character from the string starting from n to m-1

7. What will be the output of the following code? `str1 = 'Hello World!' print(str1[-1])`





ANSWER= B) `!`

8. If `str1 = 'Hello World!'`, what will be the result of `str1[2+4]`?





ANSWER= C) `W`

9. Which method returns the string in reverse order?





ANSWER= B) `[::-1]`

10. What is the output of `str1[7:2]` if `str1 = 'Hello World!'`?





ANSWER= D) `''`

11. What will the following code print? `str1 = 'hello WORLD!' print(str1.title())`





ANSWER= A) `Hello World!`

12. Which of the following is not a valid string method?





ANSWER= D) `isnumber()`

13. What does the built-in function `len()` return when applied to a string?





ANSWER= B) The number of characters in the string

14. Which method would you use to convert all characters of a string to lowercase?





ANSWER= A) `lower()`

15. If `str1 = 'Hello World!'`, what will `str1.split()` return?





ANSWER= B) `['Hello', 'World!']`

16. What will the following code print? `str1 = 'Hello World!' print(str1.replace('World', 'Everyone'))`





ANSWER= A) `Hello Everyone!`

17. What does the `strip()` method do?





ANSWER= B) Removes spaces from the beginning and end of the string

18. Which method would you use to check if a string starts with a specific substring?





ANSWER= A) `startswith()`

19. Which function would you use to convert a string to an integer?





ANSWER= B) `int()`

20. What will `str1.index('W')` return if `str1 = 'Hello World!'`?





ANSWER= B) `6`

21. How can you iterate over each character in a string using a `for` loop?





ANSWER= A) `for ch in str1:`

22. What will the following code output? `str1 = 'Hello World!' for ch in str1: print(ch, end='')`





ANSWER= C) `Hello World!`

23. Which of the following is true about string immutability in Python?





ANSWER= B) Strings cannot be modified after creation

24. Which method would you use to join elements of a list into a string?





ANSWER= C) `join()`

25. What will the following code output? `str1 = 'Hello' str2 = 'World' print(str1 + str2)`





ANSWER= B) `HelloWorld`

26. Which method would you use to find if a string contains only digits?





ANSWER= A) `isdigit()`

27. What will the following code print? `str1 = 'Hello World!' print(str1.count('o'))`





ANSWER= B) `2`

28. What is the output of `str1.find('o')` if `str1 = 'Hello World!'`?





ANSWER= A) `4`

29. Which of the following methods will return the position of the first occurrence of a substring?





ANSWER= A) `find()`

30. What will the following code print? `str1 = 'Hello World!' print(str1.upper())`





ANSWER= A) `HELLO WORLD!`

31. Which method can be used to replace parts of a string with another string?





ANSWER= B) `replace()`

32. What is the result of `str1.split(',')` if `str1 = 'apple,banana,grape'`?





ANSWER= B) `['apple', 'banana', 'grape']`

33. How can you concatenate strings in Python?





ANSWER= A) Using the `+` operator

34. What does the `format()` method do in Python strings?





ANSWER= B) It formats the string by replacing placeholders with values

35. Which of the following methods checks if all characters in a string are alphanumeric?





ANSWER= C) `isalnum()`

36. What will the following code print? `str1 = 'Hello World!' print(str1.swapcase())`





ANSWER= C) `hELLO wORLD!`

37. Which method would you use to pad a string with zeros on the left?





ANSWER= A) `zfill()`

38. What will `str1.rfind('l')` return if `str1 = 'Hello World!'`?





ANSWER= C) `9`

39. What does the `partition()` method do?





ANSWER= B) Returns a tuple with three parts: the part before the separator, the separator itself, and the part after the separator

40. What is the result of `str1.isupper()` if `str1 = 'HELLO WORLD!'`?





ANSWER= A) `True`

41. Which method returns `True` if a string contains only whitespace characters?





ANSWER= A) `isspace()`

42. What will the following code print? `str1 = 'Hello World!' print(str1.center(20, '*'))`





ANSWER= C) ` *Hello World! *`

43. Which method can be used to check if all characters in the string are lowercase?





ANSWER= A) `islower()`

44. Which method removes characters from both ends of a string?





ANSWER= A) `strip()`

1st puc computer science chapter 8 strings mcq
strings in python mcq with answers | strings in python class 11 mcq | class 11 computer chapter 8 mcq strings in python mcq with answers | strings in python class 11 mcq | class 11 computer chapter 8 mcq Reviewed by Vision Academy on September 22, 2024 Rating: 5

No comments:

CheckOut

Powered by Blogger.