{"id":1823,"date":"2022-01-18T20:18:14","date_gmt":"2022-01-18T14:48:14","guid":{"rendered":"https:\/\/cbsepython.in\/?p=1823"},"modified":"2022-01-18T20:18:14","modified_gmt":"2022-01-18T14:48:14","slug":"random-function-in-python-mcq-class-11-12","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/random-function-in-python-mcq-class-11-12\/","title":{"rendered":"Random Function in Python MCQ Class 11-12"},"content":{"rendered":"<h2><span style=\"color: #000000;\">Random Function in Python MCQ Class 11-12<\/span><\/h2>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>1. What does the following statement do?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">a) Imports the random module<\/span><\/p>\n<p><span style=\"color: #000000;\">b) Imports a random module from a list of modules<\/span><\/p>\n<p><span style=\"color: #000000;\">c) Imports the random function<\/span><\/p>\n<p><span style=\"color: #000000;\">d) imports the directory named random<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e606f7e7074700943' value='69d8b0e606f7e7074700943'><input type='hidden' id='bg-show-more-text-69d8b0e606f7e7074700943' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e606f7e7074700943' value='Hide Answer'><button id='bg-showmore-action-69d8b0e606f7e7074700943' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e606f7e7074700943' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) Imports the random module<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>2. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random as rd<\/span><\/p>\n<p><span style=\"color: #000000;\">print(rd.randint(4,7))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A random float value between 4 and 7, including 4 and 7<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A random float value between 4 and 7, excluding 4 and 7<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A random integer value between 4 and 7, excluding 4 and 7<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random integer value between 4 and 7, including 4 and 7\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6071635005927447' value='69d8b0e6071635005927447'><input type='hidden' id='bg-show-more-text-69d8b0e6071635005927447' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6071635005927447' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6071635005927447' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6071635005927447' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">d) A random integer value between 4 and 7, including 4 and 7\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>3. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random as rd<\/span><\/p>\n<p><span style=\"color: #000000;\">print(rd.random())<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A random float value between 0 and 1\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A random integer value between 0 and 1<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A random float value between 0 and 10<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random integer value between 0 and 10<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e60728a3016931566' value='69d8b0e60728a3016931566'><input type='hidden' id='bg-show-more-text-69d8b0e60728a3016931566' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e60728a3016931566' value='Hide Answer'><button id='bg-showmore-action-69d8b0e60728a3016931566' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e60728a3016931566' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) A random float value between 0 and 1\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>4. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">from random import\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">x = [0, 2, 4, 6, 8, 10]<\/span><\/p>\n<p><span style=\"color: #000000;\">print(sample(x, 3))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A dictionary containing 3 random keys from list x<\/span><\/p>\n<p><span style=\"color: #000000;\">b) Three random integer values between 0 and 10<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A list containing 3 random elements from list x\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A tuple containing 2 random elements from list x<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6073b58061482562' value='69d8b0e6073b58061482562'><input type='hidden' id='bg-show-more-text-69d8b0e6073b58061482562' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6073b58061482562' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6073b58061482562' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6073b58061482562' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">c) A list containing 3 random elements from list x\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>5. Which of the following can be a possible output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">from random import\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">print(sample(range(0,10), 3))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) [4, 11, 30]<\/span><\/p>\n<p><span style=\"color: #000000;\">b) [3, 15, 10]<\/span><\/p>\n<p><span style=\"color: #000000;\">c) [1, 5, 7, 4]<\/span><\/p>\n<p><span style=\"color: #000000;\">d) [1, 5, 0]\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6074d37044677851' value='69d8b0e6074d37044677851'><input type='hidden' id='bg-show-more-text-69d8b0e6074d37044677851' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6074d37044677851' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6074d37044677851' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6074d37044677851' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">d) [1, 5, 0]\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>6. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">x = [3, 8, 6, 5, 0]<\/span><\/p>\n<p><span style=\"color: #000000;\">print(random.choice(x))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A random element from the list x\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">b) The list x<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A random element from the list x, excluding 3 and 0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random element from the list elements 3 and 0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6075f87038830103' value='69d8b0e6075f87038830103'><input type='hidden' id='bg-show-more-text-69d8b0e6075f87038830103' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6075f87038830103' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6075f87038830103' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6075f87038830103' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) A random element from the list x\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>7. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">x = [3, 8, 6, 5, 0]<\/span><\/p>\n<p><span style=\"color: #000000;\">random.shuffle(x)<\/span><\/p>\n<p><span style=\"color: #000000;\">print(x)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A random element from the list x<\/span><\/p>\n<p><span style=\"color: #000000;\">b) The shuffled list x with the elements mixed up\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A random element from the list x, excluding 3 and 0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random element from the list elements 3 and 0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6077124041768192' value='69d8b0e6077124041768192'><input type='hidden' id='bg-show-more-text-69d8b0e6077124041768192' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6077124041768192' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6077124041768192' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6077124041768192' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">b) The shuffled list x with the elements mixed up\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>8. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">x = [3, 8, 6, 5, 0]<\/span><\/p>\n<p><span style=\"color: #000000;\">y = random.shuffle(x)<\/span><\/p>\n<p><span style=\"color: #000000;\">print(y)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A random element from the list x<\/span><\/p>\n<p><span style=\"color: #000000;\">b) The shuffled list x with the elements mixed up<\/span><\/p>\n<p><span style=\"color: #000000;\">c) None\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random element from the list x, excluding 3 and 0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e60782a9021201158' value='69d8b0e60782a9021201158'><input type='hidden' id='bg-show-more-text-69d8b0e60782a9021201158' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e60782a9021201158' value='Hide Answer'><button id='bg-showmore-action-69d8b0e60782a9021201158' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e60782a9021201158' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">c) None\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>9. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">print(int(random.random()*10))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) 10<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A random integer number within the range of 0 to 9\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">c) None<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random floating point number within the range of 0 to 9<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6079462028409066' value='69d8b0e6079462028409066'><input type='hidden' id='bg-show-more-text-69d8b0e6079462028409066' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6079462028409066' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6079462028409066' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6079462028409066' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">b) A random integer number within the range of 0 to 9\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>10. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">print(int(random.random()*10) + 1)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) 11<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A random integer number within the range of 0 to 11<\/span><\/p>\n<p><span style=\"color: #000000;\">c) None<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random whole number within the range of 1 to 10<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607a2b1057636922' value='69d8b0e607a2b1057636922'><input type='hidden' id='bg-show-more-text-69d8b0e607a2b1057636922' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607a2b1057636922' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607a2b1057636922' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607a2b1057636922' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">d) A random whole number within the range of 1 to 10<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>11. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">print(random.sample(range(20), 5))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A list of 5 unique numbers within the range of 0 to 19<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A list of 5 unique numbers within the range of 0 to 20<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A list of 4 unique numbers within the range of 0 to 19<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A tuple of 5 unique numbers within the range of 0 to 19<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607ada6046555807' value='69d8b0e607ada6046555807'><input type='hidden' id='bg-show-more-text-69d8b0e607ada6046555807' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607ada6046555807' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607ada6046555807' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607ada6046555807' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) A list of 5 unique numbers within the range of 0 to 19<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>12. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">print(random.sample(range(5, 20), 4))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) A list of 5 unique numbers within the range of 4 to 19<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A list of 5 unique numbers within the range of 5 to 20<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A list of 4 unique numbers within the range of 5 to 19\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A tuple of 4 unique numbers within the range of 5 to 19<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607b746085205398' value='69d8b0e607b746085205398'><input type='hidden' id='bg-show-more-text-69d8b0e607b746085205398' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607b746085205398' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607b746085205398' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607b746085205398' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">c) A list of 4 unique numbers within the range of 5 to 19\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>13. What will be the output after the following statements?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">x = [&#8216;Monday&#8217;, &#8216;Tuesday&#8217;, &#8216;Wednesday&#8217;, &#8216;Thursday&#8217;, &#8216;Friday&#8217;,<\/span><\/p>\n<p><span style=\"color: #000000;\">&#8216;Saturday&#8217;, &#8216;Sunday&#8217;]<\/span><\/p>\n<p><span style=\"color: #000000;\">print(x[random.randint(0, len(x) &#8211; 1)])<\/span><\/p>\n<p><span style=\"color: #000000;\">a) IndexError<\/span><\/p>\n<p><span style=\"color: #000000;\">b) A random day from all the seven days<\/span><\/p>\n<p><span style=\"color: #000000;\">c) A random day from all the days except Sunday<\/span><\/p>\n<p><span style=\"color: #000000;\">d) A random day from all the days except Monday\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607c1a2013211521' value='69d8b0e607c1a2013211521'><input type='hidden' id='bg-show-more-text-69d8b0e607c1a2013211521' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607c1a2013211521' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607c1a2013211521' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607c1a2013211521' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">d) A random day from all the days except Monday\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>14. What is the output of the program given below:<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">x = random.random()<\/span><\/p>\n<p><span style=\"color: #000000;\">y= random.randint(0,4)<\/span><\/p>\n<p><span style=\"color: #000000;\">print(int(x),\u201d:\u201d, y+int(x))<\/span><\/p>\n<p><span style=\"color: #000000;\">a) 0: 0\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">b) 2 : 4<\/span><\/p>\n<p><span style=\"color: #000000;\">c) 1: 6<\/span><\/p>\n<p><span style=\"color: #000000;\">d) 0 : 5<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607d2f3023942960' value='69d8b0e607d2f3023942960'><input type='hidden' id='bg-show-more-text-69d8b0e607d2f3023942960' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607d2f3023942960' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607d2f3023942960' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607d2f3023942960' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) 0: 0\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>15. To include the use of functions which are present in the random library, we must use the option:<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) import random<\/span><\/p>\n<p><span style=\"color: #000000;\">b) random.h<\/span><\/p>\n<p><span style=\"color: #000000;\">c) import.random<\/span><\/p>\n<p><span style=\"color: #000000;\">d) random.random<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607dea3033112888' value='69d8b0e607dea3033112888'><input type='hidden' id='bg-show-more-text-69d8b0e607dea3033112888' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607dea3033112888' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607dea3033112888' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607dea3033112888' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) import random<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>16. What is the output of the code shown below?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><\/p>\n<p><span style=\"color: #000000;\">random.choice(2,3,4)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) An integer other than 2, 3 and 4<\/span><\/p>\n<p><span style=\"color: #000000;\">b) Either 2, 3 or 4\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">c) Error<\/span><\/p>\n<p><span style=\"color: #000000;\">d) 3 only<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607ed70016584082' value='69d8b0e607ed70016584082'><input type='hidden' id='bg-show-more-text-69d8b0e607ed70016584082' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607ed70016584082' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607ed70016584082' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607ed70016584082' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">b) Either 2, 3 or 4\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>17. What is the output of the function shown below (random module has already been imported)?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">&gt;&gt;&gt;random.choice(&#8216;sun&#8217;)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) sun<\/span><\/p>\n<p><span style=\"color: #000000;\">b) u<\/span><\/p>\n<p><span style=\"color: #000000;\">c) either s, u or n\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">d) Error<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e607fd80000677539' value='69d8b0e607fd80000677539'><input type='hidden' id='bg-show-more-text-69d8b0e607fd80000677539' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e607fd80000677539' value='Hide Answer'><button id='bg-showmore-action-69d8b0e607fd80000677539' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e607fd80000677539' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">c) either s, u or n\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>18. What is the output of the function shown below if the random module has already been imported?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">&gt;&gt;&gt;import random<\/span><\/p>\n<p><span style=\"color: #000000;\">&gt;&gt;&gt;random.randint(3.5,7)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) Error<\/span><\/p>\n<p><span style=\"color: #000000;\">b) Any integer between 3.5 and 7, including 7\u00a0<\/span><\/p>\n<p><span style=\"color: #000000;\">c) Any integer between 3.5 and 7, excluding 7<\/span><\/p>\n<p><span style=\"color: #000000;\">d) The integer closest to the mean of 3.5 and 7<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6080dd9043601143' value='69d8b0e6080dd9043601143'><input type='hidden' id='bg-show-more-text-69d8b0e6080dd9043601143' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6080dd9043601143' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6080dd9043601143' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6080dd9043601143' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">b) Any integer between 3.5 and 7, including 7\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>19. Which type of elements are accepted by random.shuffle()?<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">a) strings<\/span><\/p>\n<p><span style=\"color: #000000;\">b) Lists<\/span><\/p>\n<p><span style=\"color: #000000;\">c) tuples<\/span><\/p>\n<p><span style=\"color: #000000;\">d) integers<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6081f74028414510' value='69d8b0e6081f74028414510'><input type='hidden' id='bg-show-more-text-69d8b0e6081f74028414510' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6081f74028414510' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6081f74028414510' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6081f74028414510' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">b) Lists<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>20. The output of the following Python code is either 1 or 2.<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">import random<\/span><br \/>\n<span style=\"color: #000000;\">random.randint(1,2)<\/span><\/p>\n<p><span style=\"color: #000000;\">a) True<\/span><\/p>\n<p><span style=\"color: #000000;\">b) False<\/span><\/p>\n<p><span style=\"color: #000000;\">c) none<\/span><\/p>\n<p><span style=\"color: #000000;\">d) Error<\/span><\/p>\n<p><span style=\"color: #000000;\"><input type='hidden' bg_collapse_expand='69d8b0e6082fd3018791771' value='69d8b0e6082fd3018791771'><input type='hidden' id='bg-show-more-text-69d8b0e6082fd3018791771' value='Show Answer'><input type='hidden' id='bg-show-less-text-69d8b0e6082fd3018791771' value='Hide Answer'><button id='bg-showmore-action-69d8b0e6082fd3018791771' class='bg-showmore-plg-button bg-orange-button bg-arrow '   style=\" color:#4a4949;\">Show Answer<\/button><div id='bg-showmore-hidden-69d8b0e6082fd3018791771' ><\/span><\/p>\n<p><strong><span style=\"color: #000000\">a) True<\/span><\/strong><\/p>\n<p><span style=\"color: #000000\">\u00a0<\/div><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Random Function in Python MCQ Class 11-12 &nbsp; 1. What does the following statement do? import random a) Imports the random module b) Imports a random module from a list of modules c) Imports the random function d) imports the directory named random &nbsp; 2. What will be the output after the following statements? import [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,16,20],"tags":[],"class_list":["post-1823","post","type-post","status-publish","format-standard","hentry","category-cbse-sample-papers-class-11","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\/1823","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=1823"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/1823\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=1823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=1823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=1823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}