{"id":546,"date":"2024-10-23T10:38:52","date_gmt":"2024-10-23T10:38:52","guid":{"rendered":"https:\/\/itxperts.co.in\/blog\/?p=546"},"modified":"2024-10-25T10:35:27","modified_gmt":"2024-10-25T10:35:27","slug":"50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts","status":"publish","type":"post","link":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/","title":{"rendered":"50 Core Python Questions and Answers for CBSE Class 11th &#038; 12th Students | By ITXperts"},"content":{"rendered":"\n<p>Python is a versatile and beginner-friendly programming language that is a core part of the CBSE Computer Science (CS) and Informatics Practices (IP) curriculum for Class 11th and 12th. At ITXperts, we believe in strengthening the basics of students and building a strong foundation in Python programming.<\/p>\n\n\n\n<p>Here are <strong>50 essential Python questions and answers<\/strong> designed to help CBSE students ace their exams and deepen their understanding of core Python concepts:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. What is Python?<\/strong><\/h3>\n\n\n\n<p>Python is a high-level, interpreted, general-purpose programming language known for its simplicity and readability. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. What are variables in Python?<\/strong><\/h3>\n\n\n\n<p>Variables are containers for storing data values. In Python, variables are dynamically typed, meaning you don\u2019t need to declare their type.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">x = 5\nname = \"John\"<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. How do you take input from the user in Python?<\/strong><\/h3>\n\n\n\n<p>You can use the <code>input()<\/code> function to take input from the user.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">name = input(\"Enter your name: \")\nprint(\"Hello, \" + name)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. What are data types in Python?<\/strong><\/h3>\n\n\n\n<p>Common data types in Python include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>int<\/code> for integers<\/li>\n\n\n\n<li><code>float<\/code> for floating-point numbers<\/li>\n\n\n\n<li><code>str<\/code> for strings<\/li>\n\n\n\n<li><code>bool<\/code> for boolean values<\/li>\n\n\n\n<li><code>list<\/code>, <code>tuple<\/code>, <code>dict<\/code>, <code>set<\/code> for collections<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. What is type casting in Python?<\/strong><\/h3>\n\n\n\n<p>Type casting is the conversion of one data type to another, such as converting a string to an integer using <code>int()<\/code>.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">num = int(input(\"Enter a number: \"))<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. What are comments in Python and how do you write them?<\/strong><\/h3>\n\n\n\n<p>Comments are used to explain the code and are ignored by the interpreter. You can write a comment using the <code>#<\/code> symbol.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\"># This is a comment<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7. What is the difference between <code>print()<\/code> and <code>return<\/code>?<\/strong><\/h3>\n\n\n\n<p><code>print()<\/code> displays the output on the screen, while <code>return<\/code> is used inside a function to send a value back to the caller.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>8. How do you define a function in Python?<\/strong><\/h3>\n\n\n\n<p>You can define a function using the <code>def<\/code> keyword.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def greet():\n    print(\"Hello!\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>9. What is the difference between a local and a global variable?<\/strong><\/h3>\n\n\n\n<p>A local variable is declared inside a function and can only be accessed within that function, while a global variable is declared outside all functions and can be accessed anywhere in the program.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>10. How do you create a list in Python?<\/strong><\/h3>\n\n\n\n<p>A list in Python can be created using square brackets <code>[]<\/code>.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">my_list = [1, 2, 3, 4, 5]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>11. How do you access elements in a list?<\/strong><\/h3>\n\n\n\n<p>You can access elements using their index.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">print(my_list[0])  # Output: 1<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>12. What is slicing in Python?<\/strong><\/h3>\n\n\n\n<p>Slicing is used to get a subset of a list, string, or tuple by specifying a start and end index.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">print(my_list[1:4])  # Output: [2, 3, 4]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>13. What are loops in Python?<\/strong><\/h3>\n\n\n\n<p>Loops allow you to execute a block of code repeatedly. Python supports <code>for<\/code> and <code>while<\/code> loops.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>14. Write a simple <code>for<\/code> loop to print numbers from 1 to 5.<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">for i in range(1, 6):\n    print(i)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>15. What is the <code>while<\/code> loop?<\/strong><\/h3>\n\n\n\n<p>A <code>while<\/code> loop repeats as long as a condition is true.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">i = 1\nwhile i &lt;= 5:\n    print(i)\n    i += 1<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>16. How do you handle exceptions in Python?<\/strong><\/h3>\n\n\n\n<p>You can handle exceptions using the <code>try-except<\/code> block.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">try:\n    num = int(input(\"Enter a number: \"))\nexcept ValueError:\n    print(\"Invalid input!\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>17. What is a dictionary in Python?<\/strong><\/h3>\n\n\n\n<p>A dictionary is a collection of key-value pairs.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">my_dict = {\"name\": \"John\", \"age\": 25}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>18. How do you add elements to a dictionary?<\/strong><\/h3>\n\n\n\n<p>You can add elements using a new key.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">my_dict[\"city\"] = \"New York\"<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>19. How do you remove an element from a dictionary?<\/strong><\/h3>\n\n\n\n<p>You can remove an element using the <code>del<\/code> statement or <code>pop()<\/code> method.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">del my_dict[\"age\"]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>20. What are tuples in Python?<\/strong><\/h3>\n\n\n\n<p>Tuples are immutable sequences, meaning their elements cannot be changed after creation.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">my_tuple = (1, 2, 3)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>21. What is the difference between a list and a tuple?<\/strong><\/h3>\n\n\n\n<p>Lists are mutable, while tuples are immutable. You can modify elements in a list but not in a tuple.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>22. How do you create a function with arguments in Python?<\/strong><\/h3>\n\n\n\n<p>You can pass parameters inside the parentheses of the function definition.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def add(a, b):\n    return a + b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>23. What are default arguments in Python functions?<\/strong><\/h3>\n\n\n\n<p>Default arguments are values that are used if no argument is passed.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def greet(name=\"Guest\"):\n    print(\"Hello, \" + name)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>24. What is a lambda function in Python?<\/strong><\/h3>\n\n\n\n<p>A lambda function is a small anonymous function defined using the <code>lambda<\/code> keyword.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">x = lambda a: a + 10\nprint(x(5))  # Output: 15<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>25. What are conditional statements in Python?<\/strong><\/h3>\n\n\n\n<p>Conditional statements (<code>if<\/code>, <code>elif<\/code>, <code>else<\/code>) are used to perform different actions based on conditions.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">if x &gt; 10:\n    print(\"x is greater than 10\")\nelse:\n    print(\"x is 10 or less\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>26. What is the difference between <code>is<\/code> and <code>==<\/code> in Python?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>==<\/code> checks if the values of two objects are equal.<\/li>\n\n\n\n<li><code>is<\/code> checks if two objects refer to the same location in memory.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>27. What are Python modules?<\/strong><\/h3>\n\n\n\n<p>Modules are files containing Python code, including functions, classes, or variables that can be imported into other programs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>28. How do you import a module in Python?<\/strong><\/h3>\n\n\n\n<p>You can import a module using the <code>import<\/code> statement.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import math<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>29. What is recursion in Python?<\/strong><\/h3>\n\n\n\n<p>Recursion is a process where a function calls itself.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def factorial(n):\n    if n == 1:\n        return 1\n    else:\n        return n * factorial(n-1)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>30. What is the purpose of the <code>break<\/code> statement in Python?<\/strong><\/h3>\n\n\n\n<p>The <code>break<\/code> statement is used to exit a loop prematurely.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>31. What is the <code>continue<\/code> statement?<\/strong><\/h3>\n\n\n\n<p><code>continue<\/code> skips the current iteration and moves to the next iteration of the loop.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>32. What is list comprehension in Python?<\/strong><\/h3>\n\n\n\n<p>List comprehension is a concise way to create lists.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">squares = [x**2 for x in range(5)]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>33. What is the <code>pass<\/code> statement in Python?<\/strong><\/h3>\n\n\n\n<p>The <code>pass<\/code> statement is a null statement that is used as a placeholder in loops, functions, or conditionals.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>34. How do you find the length of a list in Python?<\/strong><\/h3>\n\n\n\n<p>You can find the length using the <code>len()<\/code> function.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">print(len(my_list))<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>35. What is a <code>set<\/code> in Python?<\/strong><\/h3>\n\n\n\n<p>A set is an unordered collection of unique elements.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>36. How do you convert a list to a set?<\/strong><\/h3>\n\n\n\n<p>You can convert a list to a set using the <code>set()<\/code> function.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">my_set = set(my_list)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>37. What is a file in Python, and how do you open one?<\/strong><\/h3>\n\n\n\n<p>A file is a collection of data. You can open a file using the <code>open()<\/code> function.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">file = open(\"example.txt\", \"r\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>38. How do you write to a file in Python?<\/strong><\/h3>\n\n\n\n<p>You can write to a file using the <code>write()<\/code> method.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">file = open(\"example.txt\", \"w\")\nfile.write(\"Hello, World!\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>39. What is the purpose of the <code>with<\/code> statement in file handling?<\/strong><\/h3>\n\n\n\n<p>The <code>with<\/code> statement automatically closes the file after the block of code is executed.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>40. What are classes and objects in Python?<\/strong><\/h3>\n\n\n\n<p>A class is a blueprint for creating objects, and an object is an instance of a class.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>41. How do you define a class in Python?<\/strong><\/h3>\n\n\n\n<p>You define a class using the <code>class<\/code> keyword.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class MyClass:\n    def __init__(self, name\n\n):\n        self.name = name<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>42. What is inheritance in Python?<\/strong><\/h3>\n\n\n\n<p>Inheritance allows a class to inherit properties and methods from another class.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>43. What is polymorphism in Python?<\/strong><\/h3>\n\n\n\n<p>Polymorphism allows methods to do different things based on the object it is acting upon.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>44. What is encapsulation in Python?<\/strong><\/h3>\n\n\n\n<p>Encapsulation restricts access to certain data, ensuring that an object&#8217;s internal state is protected from outside interference.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>45. What is a constructor in Python?<\/strong><\/h3>\n\n\n\n<p>A constructor is a special method <code>__init__()<\/code> that is automatically called when an object is created.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>46. How do you check for membership in Python?<\/strong><\/h3>\n\n\n\n<p>You can check membership using the <code>in<\/code> keyword.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">if 5 in my_list:\n    print(\"Found\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>47. What is a virtual environment in Python?<\/strong><\/h3>\n\n\n\n<p>A virtual environment is an isolated environment for Python projects, ensuring that dependencies are specific to the project.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>48. What is pip in Python?<\/strong><\/h3>\n\n\n\n<p><code>pip<\/code> is the package installer for Python, used to install and manage Python libraries.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>49. What is the use of the <code>dir()<\/code> function in Python?<\/strong><\/h3>\n\n\n\n<p>The <code>dir()<\/code> function returns a list of the attributes and methods of an object.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>50. How do you handle multiple exceptions in Python?<\/strong><\/h3>\n\n\n\n<p>You can handle multiple exceptions using multiple <code>except<\/code> blocks or combining them in a tuple.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">try:\n    num = int(input(\"Enter a number: \"))\nexcept (ValueError, TypeError):\n    print(\"Invalid input!\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>By mastering these core Python concepts, students of CBSE Class 11th and 12th can build a strong foundation for programming and excel in their Computer Science and Informatics Practices courses. At <strong>ITXperts<\/strong>, we offer expert coaching to help students grasp these important concepts with clarity and confidence.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are 50 essential Python questions and answers designed to help CBSE students ace their exams and deepen their understanding of core Python concepts<\/p>\n","protected":false},"author":1,"featured_media":547,"comment_status":"open","ping_status":"open","sticky":false,"template":"custom-post-with-sidebar.php","format":"standard","meta":{"_acf_changed":false,"googlesitekit_rrm_CAow44u0DA:productID":"","footnotes":""},"categories":[44,123],"tags":[],"class_list":["post-546","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorials","category-python-worksheets"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>50 Core Python Questions and Answers for CBSE Class 11th &amp; 12th Students | By ITXperts - Itxperts<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"50 Core Python Questions and Answers for CBSE Class 11th &amp; 12th Students | By ITXperts - Itxperts\" \/>\n<meta property=\"og:description\" content=\"Here are 50 essential Python questions and answers designed to help CBSE students ace their exams and deepen their understanding of core Python concepts\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\" \/>\n<meta property=\"og:site_name\" content=\"Itxperts\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/itxperts.co.in\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-23T10:38:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-25T10:35:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1792\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"@mritxperts\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"@mritxperts\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\"},\"author\":{\"name\":\"@mritxperts\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/77ad4d47f9f82583ee23e37010a52fc6\"},\"headline\":\"50 Core Python Questions and Answers for CBSE Class 11th &#038; 12th Students | By ITXperts\",\"datePublished\":\"2024-10-23T10:38:52+00:00\",\"dateModified\":\"2024-10-25T10:35:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\"},\"wordCount\":1183,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp\",\"articleSection\":[\"Learn Python\",\"Python Worksheets\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\",\"url\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\",\"name\":\"50 Core Python Questions and Answers for CBSE Class 11th & 12th Students | By ITXperts - Itxperts\",\"isPartOf\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp\",\"datePublished\":\"2024-10-23T10:38:52+00:00\",\"dateModified\":\"2024-10-25T10:35:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage\",\"url\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp\",\"contentUrl\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp\",\"width\":1792,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/itxperts.co.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"50 Core Python Questions and Answers for CBSE Class 11th &#038; 12th Students | By ITXperts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#website\",\"url\":\"https:\/\/itxperts.co.in\/blog\/\",\"name\":\"Itxperts\",\"description\":\"Leading Website Design Company in Madhya Pradesh\",\"publisher\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/#organization\"},\"alternateName\":\"Itxperts | Website Development in Madhya Pradesh\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/itxperts.co.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#organization\",\"name\":\"Itxperts\",\"alternateName\":\"Leading Website Design Company in Madhya Pradesh \u2013 Itxperts\",\"url\":\"https:\/\/itxperts.co.in\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2025\/05\/cropped-itxperts_logo.png\",\"contentUrl\":\"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2025\/05\/cropped-itxperts_logo.png\",\"width\":512,\"height\":512,\"caption\":\"Itxperts\"},\"image\":{\"@id\":\"https:\/\/itxperts.co.in\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/itxperts.co.in\",\"https:\/\/www.linkedin.com\/company\/itxpertsshivpuri\/\",\"https:\/\/www.instagram.com\/itxperts.co.in\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/77ad4d47f9f82583ee23e37010a52fc6\",\"name\":\"@mritxperts\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/702cffafd84d85872c0d42d33a9fa39140418d7c60a1311a1f8f55b005d0570b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/702cffafd84d85872c0d42d33a9fa39140418d7c60a1311a1f8f55b005d0570b?s=96&d=mm&r=g\",\"caption\":\"@mritxperts\"},\"description\":\"I am a full-stack web developer from India with over 8 years of experience in building dynamic and responsive web solutions. Specializing in both front-end and back-end development, I have a passion for creating seamless digital experiences. When I'm not coding, I enjoy sharing insights and tutorials on the latest web technologies, helping fellow developers stay ahead in the ever-evolving tech landscape.\",\"sameAs\":[\"https:\/\/itxperts.co.in\/blog\"],\"url\":\"https:\/\/itxperts.co.in\/blog\/author\/mritxpertsgmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"50 Core Python Questions and Answers for CBSE Class 11th & 12th Students | By ITXperts - Itxperts","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/","og_locale":"en_US","og_type":"article","og_title":"50 Core Python Questions and Answers for CBSE Class 11th & 12th Students | By ITXperts - Itxperts","og_description":"Here are 50 essential Python questions and answers designed to help CBSE students ace their exams and deepen their understanding of core Python concepts","og_url":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/","og_site_name":"Itxperts","article_publisher":"https:\/\/www.facebook.com\/itxperts.co.in","article_published_time":"2024-10-23T10:38:52+00:00","article_modified_time":"2024-10-25T10:35:27+00:00","og_image":[{"width":1792,"height":1024,"url":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp","type":"image\/webp"}],"author":"@mritxperts","twitter_card":"summary_large_image","twitter_misc":{"Written by":"@mritxperts","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#article","isPartOf":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/"},"author":{"name":"@mritxperts","@id":"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/77ad4d47f9f82583ee23e37010a52fc6"},"headline":"50 Core Python Questions and Answers for CBSE Class 11th &#038; 12th Students | By ITXperts","datePublished":"2024-10-23T10:38:52+00:00","dateModified":"2024-10-25T10:35:27+00:00","mainEntityOfPage":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/"},"wordCount":1183,"commentCount":0,"publisher":{"@id":"https:\/\/itxperts.co.in\/blog\/#organization"},"image":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage"},"thumbnailUrl":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp","articleSection":["Learn Python","Python Worksheets"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/","url":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/","name":"50 Core Python Questions and Answers for CBSE Class 11th & 12th Students | By ITXperts - Itxperts","isPartOf":{"@id":"https:\/\/itxperts.co.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage"},"image":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage"},"thumbnailUrl":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp","datePublished":"2024-10-23T10:38:52+00:00","dateModified":"2024-10-25T10:35:27+00:00","breadcrumb":{"@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#primaryimage","url":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp","contentUrl":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2024\/10\/itxperts-2.webp","width":1792,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/itxperts.co.in\/blog\/50-core-python-questions-and-answers-for-cbse-class-11th-12th-students-by-itxperts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itxperts.co.in\/blog\/"},{"@type":"ListItem","position":2,"name":"50 Core Python Questions and Answers for CBSE Class 11th &#038; 12th Students | By ITXperts"}]},{"@type":"WebSite","@id":"https:\/\/itxperts.co.in\/blog\/#website","url":"https:\/\/itxperts.co.in\/blog\/","name":"Itxperts","description":"Leading Website Design Company in Madhya Pradesh","publisher":{"@id":"https:\/\/itxperts.co.in\/blog\/#organization"},"alternateName":"Itxperts | Website Development in Madhya Pradesh","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itxperts.co.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/itxperts.co.in\/blog\/#organization","name":"Itxperts","alternateName":"Leading Website Design Company in Madhya Pradesh \u2013 Itxperts","url":"https:\/\/itxperts.co.in\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itxperts.co.in\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2025\/05\/cropped-itxperts_logo.png","contentUrl":"https:\/\/itxperts.co.in\/blog\/wp-content\/uploads\/2025\/05\/cropped-itxperts_logo.png","width":512,"height":512,"caption":"Itxperts"},"image":{"@id":"https:\/\/itxperts.co.in\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/itxperts.co.in","https:\/\/www.linkedin.com\/company\/itxpertsshivpuri\/","https:\/\/www.instagram.com\/itxperts.co.in\/"]},{"@type":"Person","@id":"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/77ad4d47f9f82583ee23e37010a52fc6","name":"@mritxperts","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itxperts.co.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/702cffafd84d85872c0d42d33a9fa39140418d7c60a1311a1f8f55b005d0570b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/702cffafd84d85872c0d42d33a9fa39140418d7c60a1311a1f8f55b005d0570b?s=96&d=mm&r=g","caption":"@mritxperts"},"description":"I am a full-stack web developer from India with over 8 years of experience in building dynamic and responsive web solutions. Specializing in both front-end and back-end development, I have a passion for creating seamless digital experiences. When I'm not coding, I enjoy sharing insights and tutorials on the latest web technologies, helping fellow developers stay ahead in the ever-evolving tech landscape.","sameAs":["https:\/\/itxperts.co.in\/blog"],"url":"https:\/\/itxperts.co.in\/blog\/author\/mritxpertsgmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/posts\/546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/comments?post=546"}],"version-history":[{"count":1,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/posts\/546\/revisions"}],"predecessor-version":[{"id":548,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/posts\/546\/revisions\/548"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/media\/547"}],"wp:attachment":[{"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/media?parent=546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/categories?post=546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itxperts.co.in\/blog\/wp-json\/wp\/v2\/tags?post=546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}