{"id":3411,"date":"2022-09-17T00:29:24","date_gmt":"2022-09-16T18:59:24","guid":{"rendered":"https:\/\/cbsepython.in\/?p=3411"},"modified":"2022-09-17T00:29:24","modified_gmt":"2022-09-16T18:59:24","slug":"string-manipulation-in-python-questions-and-answers","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/string-manipulation-in-python-questions-and-answers\/","title":{"rendered":"String Manipulation in Python Questions and Answers Class 11-12"},"content":{"rendered":"<h2><span style=\"color: #000000;\">String Manipulation in Python Questions and Answers Class 11-12<\/span><\/h2>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.1 : Which\u00a0 of\u00a0 the\u00a0 following returns a copy of\u00a0 the string with its first character\u00a0 capitalized ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) string.upper()<\/span><\/p>\n<p><span style=\"color: #000000;\">b) string.capitalize()<\/span><\/p>\n<p><span style=\"color: #000000;\">c) capitalize()<\/span><\/p>\n<p><span style=\"color: #000000;\">d) all\u00a0 of these<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.2:Which of the following\u00a0 is not a python legal string operation ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) &#8216;abc&#8217; + &#8216;abc&#8217;<\/span><\/p>\n<p><span style=\"color: #000000;\">b) &#8216;abc&#8217; * 3<\/span><\/p>\n<p><span style=\"color: #000000;\">c) &#8216;abc&#8217; + 3<\/span><\/p>\n<p><span style=\"color: #000000;\">d) &#8216;abc&#8217;.lower()<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.3: Out\u00a0 of\u00a0 the following\u00a0 operators , which one\u00a0 cannot\u00a0 be used with strings ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) &lt;&gt;<\/span><\/p>\n<p><span style=\"color: #000000;\">b) *<\/span><\/p>\n<p><span style=\"color: #000000;\">c) +<\/span><\/p>\n<p><span style=\"color: #000000;\">d) in<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.4: The _________ function\u00a0 returns the ASCII value\u00a0 of given character ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) ord()<\/span><\/p>\n<p><span style=\"color: #000000;\">b) chr()<\/span><\/p>\n<p><span style=\"color: #000000;\">c) varchar()<\/span><\/p>\n<p><span style=\"color: #000000;\">d) none of these<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.5 : For\u00a0 a string\u00a0 s\u00a0 storing &#8216;Goldy&#8217; what would s[0]\u00a0 and s[-1]\u00a0 return ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) g ,y<\/span><\/p>\n<p><span style=\"color: #000000;\">b) G,y<\/span><\/p>\n<p><span style=\"color: #000000;\">c) G,d<\/span><\/p>\n<p><span style=\"color: #000000;\">d) None<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.6 : ________ refers to iterating\u00a0 through\u00a0 the elements\u00a0 of\u00a0 a string , one character at a time.<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">Answer : Traversing<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q.7 : What is the output\u00a0 produced\u00a0 by\u00a0 following expressions ?<\/strong><\/span><\/p>\n<ol style=\"list-style-type: lower-roman;\">\n<li><span style=\"color: #000000;\">&#8220;The &#8220;<\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q. 8: What\u00a0 do you understand by string slices?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">Answer : Slicing is\u00a0the process of obtaining a portion (substring) of a string by using its indices. Given a string, we can use the following template to slice it and obtain a substring: string[start:end] start is the index from where we want the substring to start.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q. 9: What\u00a0 is the role of these functions ?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) isalpha()<\/span><\/p>\n<p><span style=\"color: #000000;\">b) isalnum()<\/span><\/p>\n<p><span style=\"color: #000000;\">c) isdigit()<\/span><\/p>\n<p><span style=\"color: #000000;\">d) isspace()<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\">Answer:<\/span><\/p>\n<p><span style=\"color: #000000;\">isalpha() : returns true if there all\u00a0 characters in string are alphabetic<\/span><\/p>\n<p><span style=\"color: #000000;\">isalnum(): <b>returns True if all the characters are alphanumeric<\/b><\/span><\/p>\n<p><span style=\"color: #000000;\">isdigit(): returns True if all the characters are digits<\/span><\/p>\n<p><span style=\"color: #000000;\">isspace(): returns True if all the characters in a string are whitespaces<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q. 10 : What\u00a0 are membership operators? What do they basically do?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">Answer :<\/span><\/p>\n<p><span style=\"color: #000000;\">The membership operators are, as the name explains,\u00a0used to verify a value membership. The operators are used to figure out if there are two forms of value as a part of a sequence, such as string or list membership operators: in and not in<\/span><\/p>\n<p><span style=\"color: #000000;\">The last character of a string S is at index len(s) -1 . (True\/False)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Q. 11 : How are string internally\u00a0 stored?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">Answer :<\/span><\/p>\n<p><span style=\"color: #000000;\">Python stores strings as sequences of unicode characters. Unicode characters are stored with either 1, 2, or 4 bytes depending on the size of their encoding. Byte size of strings increases proportionally with the size of its largest character, since all characters must be of the same size.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>String Manipulation in Python Questions and Answers Class 11-12 &nbsp; Q.1 : Which\u00a0 of\u00a0 the\u00a0 following returns a copy of\u00a0 the string with its first character\u00a0 capitalized ? a) string.upper() b) string.capitalize() c) capitalize() d) all\u00a0 of these &nbsp; Q.2:Which of the following\u00a0 is not a python legal string operation ? a) &#8216;abc&#8217; + &#8216;abc&#8217; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,20],"tags":[],"class_list":["post-3411","post","type-post","status-publish","format-standard","hentry","category-cbse-sample-papers-class-12","category-cbse-computer-science-with-python-class-12"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/3411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=3411"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/3411\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=3411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=3411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=3411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}