

{"id":70268,"date":"2019-10-03T09:59:11","date_gmt":"2019-10-03T04:29:11","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=70268"},"modified":"2019-10-04T09:29:14","modified_gmt":"2019-10-04T03:59:14","slug":"python-interview-questions","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/","title":{"rendered":"71 Python Interview Questions and Answers [New] &#8211; Get Ready for Technical Round"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1379,&quot;href&quot;:&quot;https:\\\/\\\/www.python.org\\\/about\\\/gettingstarted&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251206211720\\\/https:\\\/\\\/www.python.org\\\/about\\\/gettingstarted\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 05:59:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-12 14:23:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-15 14:47:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-18 15:58:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-22 06:19:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-26 11:50:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-30 14:27:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-02 16:02:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-07 02:57:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 01:34:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-15 15:35:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-19 04:12:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-22 05:11:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-25 23:31:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-30 06:45:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-02 08:51:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-07 06:25:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 16:26:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 18:58:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-18 13:30:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 15:40:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 18:13:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 08:53:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 05:53:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 06:52:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-14 12:51:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 18:37:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 07:40:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 15:07:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-27 19:41:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 15:19:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 21:00:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-07 04:00:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 09:44:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 04:25:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 18:46:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 14:41:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-24 15:21:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-29 07:27:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-02 13:42:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-09 04:11:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-12 06:51:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-17 17:30:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-21 00:46:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-25 01:39:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-28 05:23:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-02 00:36:51&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-06-06 13:57:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-10 13:58:08&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-10 13:58:08&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Welcome to the second part of DataFlair&#8217;s Python Interview Questions and Answer Series. If you are the first time visitor then you must take a quick look at the series &#8211;<\/p>\n<ul>\n<li><em><strong><a href=\"https:\/\/data-flair.training\/blogs\/top-python-interview-questions-answer\/\">Python Interview Questions and Answers for Freshers<\/a><\/strong><\/em><\/li>\n<li><em><strong>Python Interview Questions and Answers for Intermediate<\/strong><\/em><\/li>\n<li><em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-programming-interview-questions\/\">Python Interview Questions and Answers for Experienced<\/a><\/strong><\/em><\/li>\n<\/ul>\n<p>As I told you, this is the second part, it mainly focuses on intermediates. In all the parts we have divided the questions into below subcategories so that it will be easier for you to find the question and answer you are searching for. Also, as per the feedback, this is the best way for Python Interview Preparations. Have a look &#8211;<\/p>\n<ul>\n<li>Basic Python Interview Questions for Intermediates<\/li>\n<li>Top Python Interview Questions<\/li>\n<li>Python Developer Interview Questions<\/li>\n<li>Python OOPS and Library Interview Questions<\/li>\n<li>Technical Python Interview Questions and Answers<\/li>\n<li>Advanced Python Interview Questions<\/li>\n<li>Open-ended Python Interview Questions<\/li>\n<\/ul>\n<h3>Basic Python Interview Questions for Intermediates<\/h3>\n<p>Below are some basic python interview questions for intermediates, I recommend you to try to answer them by yourself. If you feel you are not able to answer the question, refer to the answers given by interview experienced.<\/p>\n<p><strong>Q.1. When is the else part of a try-except block executed?<\/strong><\/p>\n<p>In an if-else block, the else part is executed when the condition in the if-statement is False. But with a try-except block, the else part executes only if no exception is raised in the try part.<\/p>\n<p><strong>Q.2. If a list is nums=[0,1,2,3,4], what is nums[-1]?<\/strong><\/p>\n<p>This code does not throw an exception. nums[-1] is 4 because it begins traversing from right<\/p>\n<p><strong>Q.3.\u00a0What is the PYTHONPATH variable?<\/strong><\/p>\n<p>PYTHONPATH is the variable that tells the interpreter where to locate the module files imported into a program. Hence, it must include the Python source library directory and the directories containing Python source code. You can manually set PYTHONPATH, but usually, the Python installer will preset it.<\/p>\n<p><strong>Q.4. Explain join() and split() in Python.<\/strong><\/p>\n<p>join() lets us join characters from a string together by a character we specify.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ','.join('12345')<\/pre>\n<p><strong>\u20181,2,3,4,5\u2019<\/strong><\/p>\n<p>split() lets us split a string around the character we specify.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; '1,2,3,4,5'.split(',')<\/pre>\n<p><strong>[\u20181\u2019, \u20182\u2019, \u20183\u2019, \u20184\u2019, \u20185\u2019]<\/strong><\/p>\n<p><strong>Q.5. Explain the output of the following piece of code-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x=[\u2018ab\u2019,\u2019cd\u2019]\r\nprint(len(map(list,x)))<\/pre>\n<p>This actually gives us an error- a TypeError. This is because map() has no len() attribute in their dir().<\/p>\n<p class=\"df-text-bold\" style=\"text-align: center\"><span class=\"df-text-red\">Important for Interview<\/span> &#8211; <a href=\"https:\/\/data-flair.training\/blogs\/python-projects-with-source-code\/\">Package of top 5 Python Projects with source code<\/a><\/p>\n<p><strong>Q.6. Explain a few methods to implement Functionally Oriented Programming in Python.<\/strong><\/p>\n<p>Sometimes, when we want to iterate over a list, a few methods come in handy.<\/p>\n<p><strong>a. filter()<\/strong><\/p>\n<p>Filter lets us filter in some values based on conditional logic.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list(filter(lambda x:x&gt;5,range(8)))<\/pre>\n<p><strong>[6, 7]<\/strong><\/p>\n<p><strong>b. map()<\/strong><\/p>\n<p>Map applies a function to every element in an iterable.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list(map(lambda x:x**2,range(8)))<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[0, 1, 4, 9, 16, 25, 36, 49]<\/pre>\n<p><strong>c. reduce()<\/strong><\/p>\n<p>Reduce repeatedly reduces a sequence pair-wise until we reach a single value.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; from functools import reduce\r\n&gt;&gt;&gt; reduce(lambda x,y:x-y,[1,2,3,4,5])<\/pre>\n<p><strong>-13<\/strong><\/p>\n<p><strong>Q.7. So what is the output of the following piece of code?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x=[\u2018ab\u2019,\u2019cd\u2019]\r\nprint(len(list(map(list,x))))<\/pre>\n<p>This outputs 2 because the length of this list is 2. list(map(list,x)) is [[&#8216;a&#8217;, &#8216;b&#8217;], [&#8216;c&#8217;, &#8216;d&#8217;]], and the length of this is 2.<\/p>\n<p><strong>Q.8. Is del the same as remove()? What are they?<\/strong><\/p>\n<p>del and remove() are methods on lists\/ ways to eliminate elements.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list=[3,4,5,6,7]\r\n&gt;&gt;&gt; del list[3]\r\n&gt;&gt;&gt; list<\/pre>\n<p><strong>[3, 4, 5, 7]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list.remove(5)\r\n&gt;&gt;&gt; list<\/pre>\n<p><strong>[3, 4, 7]<\/strong><\/p>\n<p>While del lets us delete an element at a certain index, remove() lets us remove an element by its value.<\/p>\n<p><strong>Q.9. How do you open a file for writing?<\/strong><\/p>\n<p>Let\u2019s create a text file on our Desktop and call it tabs.txt. To open it to be able to write to it, use the following line of code-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; file=open('tabs.txt','w')<\/pre>\n<p>This opens the file in writing mode. You should close it once you\u2019re done.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; file.close()<\/pre>\n<p><strong>Q.10. Explain the output of the following piece of code-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; tuple=(123,'John')\r\n&gt;&gt;&gt; tuple*=2\r\n&gt;&gt;&gt; tuple<\/pre>\n<p><strong>(123, \u2018John\u2019, 123, \u2018John\u2019)<\/strong><\/p>\n<p>In this code, we multiply the tuple by 2. This duplicates its contents, hence, giving us (123, \u2018John\u2019, 123, \u2018John\u2019). We can also do this to strings:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; 'ba'+'na'*2<\/pre>\n<p><strong>\u2018banana\u2019<\/strong><\/p>\n<p><strong>Q.11. Differentiate between the append() and extend() methods of a list.<\/strong><\/p>\n<p>The methods append() and extend() work on lists. While append() adds an element to the end of the list, extend adds another list to the end of a list.<\/p>\n<p>Let\u2019s take two lists.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1,list2=[1,2,3],[5,6,7,8]<\/pre>\n<p>This is how append() works:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1.append(4)\r\n&gt;&gt;&gt; list1<\/pre>\n<p><strong>[1, 2, 3, 4]<\/strong><\/p>\n<p>And this is how extend() works:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1.extend(list2)\r\n&gt;&gt;&gt; list1<\/pre>\n<p><strong>[1, 2, 3, 4, 5, 6, 7, 8]<\/strong><\/p>\n<p><em><strong>You must check the detailed description for <a href=\"https:\/\/data-flair.training\/blogs\/python-lists-examples\/\">Lists in Python<\/a><\/strong><\/em><\/p>\n<p><strong>Q.12. What are the different file-processing modes with Python?<\/strong><\/p>\n<p>We have the following modes-<\/p>\n<ul>\n<li>read-only \u2013 \u2018r\u2019<\/li>\n<li>write-only \u2013 \u2018w\u2019<\/li>\n<li>read-write \u2013 \u2018rw\u2019<\/li>\n<li>append \u2013 \u2018a\u2019<\/li>\n<\/ul>\n<p>We can open a text file with the option \u2018t\u2019. So to open a text file to read it, we can use the mode \u2018rt\u2019. Similarly, for binary files, we use \u2018b\u2019.<\/p>\n<p><strong>Q.13. What does the map() function do?<\/strong><\/p>\n<p>map() executes the function we pass to it as the first argument; it does so on all elements of the iterable in the second argument. Let\u2019s take an example, shall we?<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; for i in map(lambda i:i**3, (2,3,7)):\r\nprint(i)<\/pre>\n<p><strong>8<\/strong><br \/>\n<strong>27<\/strong><br \/>\n<strong>343<\/strong><\/p>\n<p>This gives us the cubes of the values 2, 3, and 7.<\/p>\n<p><strong>Q.14. Explain try, raise, and finally.<\/strong><\/p>\n<p>These are the keywords we use with <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-exception-handling\/\">exception-handling<\/a><\/strong><\/em>. We put risky code under a try block, use the raise statement to explicitly raise an error, and use the finally block to put code that we want to execute anyway.<\/p>\n<p><strong>Q.15. What happens if we do not handle an error in the except block?<\/strong><\/p>\n<p>If we don\u2019t do this, the program terminates. Then, it sends an execution trace to sys.stderr.<\/p>\n<p><strong>Q.16. Is there a way to remove the last object from a list?<\/strong><\/p>\n<p>Yes, there is. Try running the following piece of code-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list=[1,2,3,4,5\r\n&gt;&gt;&gt; list.pop(-1)<\/pre>\n<p><strong>5<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list<\/pre>\n<p><strong>[1, 2, 3, 4]<\/strong><\/p>\n<p><strong>Q.17. How will you convert an integer to a Unicode character?<\/strong><\/p>\n<p>This is simple. All we need is the chr(x) built-in function. See how.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; chr(52)<\/pre>\n<p><strong>\u20184\u2019<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; chr(49)<\/pre>\n<p><strong>\u20181\u2019<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; chr(67)<\/pre>\n<p><strong>\u2018C\u2019<\/strong><\/p>\n<p><em><strong>Don&#8217;t forget to check DataFlair&#8217;s latest guide on <a href=\"https:\/\/data-flair.training\/blogs\/python-built-in-functions\/\">Python Built-in Functions<\/a><\/strong><\/em><\/p>\n<p><strong>Q.18. Explain the problem with the following piece of code-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; def func(n=[]):\r\n              #playing around\r\n               pass\r\n&gt;&gt;&gt; func([1,2,3])\r\n&gt;&gt;&gt; func()\r\n&gt;&gt;&gt; n<\/pre>\n<p>The request for n raises a NameError. This is since n is a variable local to func and we cannot access it elsewhere. It is also true that Python only evaluates default parameter values once; every invocation shares the default value. If one invocation modifies it, that is what another gets. This means you should only ever use primitives, strings, and tuples as default parameters, not mutable objects.<\/p>\n<p><strong>Q.19. What do you see below?<\/strong><\/p>\n<p><strong>s = a + \u2018[\u2018 + b + \u2018:\u2019 + c + \u2018]\u2019<\/strong><\/p>\n<p>This is string concatenation. If a, b, and c are strings themselves, then it works fine and concatenates the strings around the strings \u2018[\u2018, \u2018:\u2019, and \u2018]\u2019 as mentioned. If even one of these isn\u2019t a string, this raises a TypeError.<\/p>\n<p><strong>Q.20. So does recursion cause any trouble?<\/strong><\/p>\n<p>Sure does:<\/p>\n<ul>\n<li>Needs more function calls.<\/li>\n<li>Each function call stores a state variable to the program stack- consumes memory, can cause memory overflow.<\/li>\n<li>Calling a function consumes time.<\/li>\n<\/ul>\n<p><strong>Q.21. What good is recursion?<\/strong><\/p>\n<p>With <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/recursion-in-python\/\">recursion<\/a><\/strong><\/em>, we observe the following:<\/p>\n<ul>\n<li>Need to put in less efforts.<\/li>\n<li>Smaller code than that by loops.<\/li>\n<li>Easier-to-understand code.<\/li>\n<\/ul>\n<p><strong>Q.22. What does the following code give us?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; b=(1)<\/pre>\n<p>Not a tuple. This gives us a plain integer.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(b)<\/pre>\n<p><strong>&lt;class \u2018int\u2019&gt;<\/strong><\/p>\n<p>To let it be a tuple, we can declare so explicitly with a comma after 1:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; b=(1,)\r\n&gt;&gt;&gt; type(b)<\/pre>\n<p><strong>&lt;class \u2018tuple\u2019&gt;<\/strong><\/p>\n<p><strong>Q.23. Why are identifier names with a leading underscore disparaged?<\/strong><\/p>\n<p>Since <a href=\"https:\/\/www.python.org\/about\/gettingstarted\/\">Python<\/a> does not have a concept of private variables, it is a convention to use leading underscores to declare a variable private. This is why we mustn\u2019t do that to variables we do not want to make private.<\/p>\n<p><strong>Q.24. Can you remove the whitespaces from the string \u201caaa bbb ccc ddd eee\u201d?<\/strong><\/p>\n<p>I can think of three ways to do this.<\/p>\n<p>Using join-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; s='aaa bbb ccc ddd eee'\r\n&gt;&gt;&gt; s1=''.join(s.split())\r\n&gt;&gt;&gt; s1<\/pre>\n<p><strong>\u2018aaabbbcccdddeee\u2019<\/strong><\/p>\n<p>Using a <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-list-comprehension\/\">list comprehension<\/a><\/strong><\/em>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; s='aaa bbb ccc ddd eee'\r\n&gt;&gt;&gt; s1=str(''.join(([i for i in s if i!=' '])))\r\n&gt;&gt;&gt; s1<\/pre>\n<p><strong>\u2018aaabbbcccdddeee\u2019<\/strong><\/p>\n<p>Using replace()-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; s='aaa bbb ccc ddd eee'\r\n&gt;&gt;&gt; s1 = s.replace(' ','')\r\n&gt;&gt;&gt; s1<\/pre>\n<p><strong>\u2018aaabbbcccdddeee\u2019<\/strong><\/p>\n<p><strong>Q.25. How do you get the current working directory using Python?<\/strong><\/p>\n<p>Working on software with Python, you may need to read and write files from various directories. To find out which directory we\u2019re presently working under, we can borrow the getcwd() method from the os module.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import os\r\n&gt;&gt;&gt; os.getcwd()<\/pre>\n<p><strong>\u2018C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37-32\u2019<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"><\/pre>\n<h3>Top Python Interview Questions and Answers<\/h3>\n<p><strong>Q.26. How would you randomize the contents of a list in-place?<\/strong><\/p>\n<p>For this, we\u2019ll import the function shuffle() from the module random.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; from random import shuffle\r\n&gt;&gt;&gt; shuffle(mylist)\r\n&gt;&gt;&gt; mylist<\/pre>\n<p><strong>[3, 4, 8, 0, 5, 7, 6, 2, 1]<\/strong><\/p>\n<p><strong>Q.27. How do you remove the leading whitespace in a string?<\/strong><\/p>\n<p>Leading whitespace in a string is the whitespace in a string before the first non-whitespace character. To remove it from a string, we use the method lstrip().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ' Ayushi '.lstrip()<\/pre>\n<p><strong>\u2018Ayushi \u2018<\/strong><\/p>\n<p>As you can see, this string had both leading and trailing whitespaces. lstrip() stripped the string of the leading whitespace. If we want to strip the trailing whitespace instead, we use rstrip().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ' Ayushi '.rstrip()<\/pre>\n<p><strong>\u2018 Ayushi\u2019<\/strong><\/p>\n<p><strong>Q.28. Below, we give you code to remove numbers smaller than 5 from the list nums. However, it does not work as expected. Can you point out the bug for us?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; nums=[1,2,5,10,3,100,9,24]\r\n&gt;&gt;&gt; for i in nums:\r\n             if i&lt;5:\r\n                         nums.remove(i)\r\n&gt;&gt;&gt; nums<\/pre>\n<p><strong>[2, 5, 10, 100, 9, 24]<\/strong><\/p>\n<p>This code checks for each element in nums- is it smaller than 5? If it is, it removes that element. In the first iteration, 1 indeed is smaller than 5. So it removes that from this list. But this disturbs the indices. Hence, it checks the element 5, but not the element 2. For this situation, we have three workarounds:<\/p>\n<p>Create an empty array and append to that-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; nums=[1,2,5,10,3,100,9,24]\r\n&gt;&gt;&gt; newnums=[]\r\n&gt;&gt;&gt; for i in nums:\r\n       if i&gt;=5:\r\nnewnums.append(i)\r\n&gt;&gt;&gt; newnums<\/pre>\n<p><strong>[5, 10, 100, 9, 24]<\/strong><\/p>\n<p>Using a list comprehension-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; nums=[1,2,5,10,3,100,9,24]\r\n&gt;&gt;&gt; newnums=[i for i in nums if i&gt;=5]\r\n&gt;&gt;&gt; newnums<\/pre>\n<p><strong>[5, 10, 100, 9, 24]<\/strong><\/p>\n<p>Using the filter() function-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; nums=[1,2,5,10,3,100,9,24]\r\n&gt;&gt;&gt; newnums=list(filter(lambda x:x&gt;=5, nums))\r\n&gt;&gt;&gt; newnums<\/pre>\n<p><strong>[5, 10, 100, 9, 24]<\/strong><\/p>\n<p><strong>Q.29. What is the enumerate() function in Python?<\/strong><\/p>\n<p>enumerate() iterates through a sequence and extracts the index position and its corresponding value too.<\/p>\n<p>Let\u2019s take an example.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; for i,v in enumerate(['Python','C++','Scala']):\r\n        print(i,v)<\/pre>\n<p><strong>0 Python<\/strong><br \/>\n<strong>1 C++<\/strong><br \/>\n<strong>2 Scala<\/strong><\/p>\n<p><strong>Q.30. How will you create the following pattern using Python?<\/strong><br \/>\n*<br \/>\n**<br \/>\n***<br \/>\n****<br \/>\n*****<\/p>\n<p>We will use two for-loops for this.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; for i in range(1,6):\r\n       for j in range(1,i+1):\r\n                 print('*',end='')\r\n       print()<\/pre>\n<p><strong>Q.31. Where will you use while rather than for?<\/strong><\/p>\n<p>Although we can do with for all that we can do with while, there are some places where a while loop will make things easier-<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-70432\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop.png\" alt=\"python advanced interview questions\" width=\"442\" height=\"170\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop.png 582w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop-150x58.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop-300x115.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-while-loop-vs-for-loop-520x200.png 520w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/a><\/p>\n<ul>\n<li>For simple repetitive looping<\/li>\n<li>When we don\u2019t need to iterate through a list of items- like database records and characters in a string.<\/li>\n<\/ul>\n<p><em><strong>Want to revise the concepts of loops? Here it is &#8211; <a href=\"https:\/\/data-flair.training\/blogs\/python-loops\/\">Python Loops<\/a><\/strong><\/em><\/p>\n<p><strong>Q.32. Take a look at this piece of code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; A0= dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))\r\n&gt;&gt;&gt; A1= range(10)\r\n&gt;&gt;&gt; A2= sorted([i for i in A1 if i in A0])\r\n&gt;&gt;&gt; A3= sorted([A0[s] for s in A0])\r\n&gt;&gt;&gt; A4= [i for i in A1 if i in A3]\r\n&gt;&gt;&gt; A5= {i:i*i for i in A1}\r\n&gt;&gt;&gt; A6= [[i,i*i] for i in A1]\r\n&gt;&gt;&gt; A0,A1,A2,A3,A4,A5,A6<\/pre>\n<p>What are the values of variables A0 to A6? Explain.<\/p>\n<p>Here you go:<\/p>\n<p><strong>A0= {&#8216;a&#8217;: 1, &#8216;b&#8217;: 2, &#8216;c&#8217;: 3, &#8216;d&#8217;: 4, &#8216;e&#8217;: 5}<\/strong><br \/>\n<strong>A1= range(0, 10)<\/strong><br \/>\n<strong>A2= []<\/strong><br \/>\n<strong>A3= [1, 2, 3, 4, 5]<\/strong><br \/>\n<strong>A4= [1, 2, 3, 4, 5]<\/strong><br \/>\n<strong>A5= {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}<\/strong><br \/>\n<strong>A6= [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]]<\/strong><\/p>\n<p>Now to find out what happened. A0 zips \u2018a\u2019 with 1, \u2018b\u2019 with 2, and so on. This results in tuples, which the call to dict() then turns into a dictionary by using these as keys and values.<\/p>\n<ul>\n<li>A1 gives us a range object with start=0 and stop=10.<\/li>\n<li>A2 checks each item in A1- does it exist in A0 as well? If it does, it adds it to a list. Finally, it sorts this list. Since no items exist in both A0 and A1, this gives us an empty list.<\/li>\n<li>A3 takes each key in A0 and returns its value. This gives us the list [1,2,3,4,5].<\/li>\n<li>A4 checks each item in A1- does it exist in A3 too? If it does, it adds it to a list and returns this list.<\/li>\n<li>A5 takes each item in A1, squares it, and returns a dictionary with the items in A1 as keys and their squares as the corresponding values.<\/li>\n<li>A6 takes each item in A1, then returns sublists containing those items and their squares- one at a time.<\/li>\n<\/ul>\n<p><strong>Q.33. Does Python have a switch-case statement?<\/strong><\/p>\n<p>In languages like C++, we have something like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">switch(name)\r\n{\r\n   case \u2018Ayushi\u2019:\r\n       cout&lt;&lt;\u201dMonday\u201d;\r\n       break;\r\n   case \u2018Megha\u2019:\r\n       cout&lt;&lt;\u201dTuesday\u201d;\r\n       break;\r\n   default:\r\n       cout&lt;&lt;\u201dHi, user\u201d;\r\n}<\/pre>\n<p>But in Python, we do not have a<em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-switch-case\/\"> switch-case statement<\/a><\/strong><\/em>. Here, you may write a switch function to use. Else, you may use a set of if-elif-else statements. To implement a function for this, we may use a dictionary.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; def switch(choice):\r\n   switcher={\r\n       'Ayushi':'Monday',\r\n       'Megha':'Tuesday',\r\n      print(switcher.get(choice,'Hi, user'))<\/pre>\n<p><strong>return<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; switch('Megha')<\/pre>\n<p><strong>Tuesday<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; switch('Ayushi')<\/pre>\n<p><strong>Monday<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; switch('Ruchi')<\/pre>\n<p><strong>Hi, user<\/strong><\/p>\n<p>Here, the get() method returns the value of the key. When no key matches, the default value (the second argument) is returned.<\/p>\n<p><strong>Q.34. Differentiate between deep and shallow copy.<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-70431\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy.png\" alt=\"python basic interview questions\" width=\"377\" height=\"145\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy.png 582w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy-150x58.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy-300x115.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-deep-copy-vs-shallow-copy-520x200.png 520w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/a><\/p>\n<p>A deep copy copies an object into another. This means that if you make a change to a copy of an object, it won\u2019t affect the original object. In Python, we use the function deepcopy() for this, and we import the module copy. We use it like:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import copy\r\n&gt;&gt;&gt; b=copy.deepcopy(a)<\/pre>\n<p>A shallow copy, however, copies one object\u2019s reference to another. So, if we make a change in the copy, it will affect the original object. For this, we have the function copy(). We use it like:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; b=copy.copy(a)<\/pre>\n<h3>Python Developer Interview Questions<\/h3>\n<p><strong>Q.35. Can you make a local variable\u2019s name begin with an underscore? (developer)<\/strong><\/p>\n<p>You can, but you should not. This is because:<\/p>\n<p>Local variables indicate private variables of a class, and so, they confuse the interpreter.<\/p>\n<p><strong>Q.36. Is a NumPy array better than a list?<\/strong><\/p>\n<p>NumPy arrays have 3 benefits over lists:<\/p>\n<ul>\n<li>They are faster<\/li>\n<li>They require less memory<\/li>\n<li>They are more convenient to work with<\/li>\n<\/ul>\n<p><strong>Q.37. If you installed a module with pip but it doesn\u2019t import in your IDLE, what could it possibly be?<\/strong><\/p>\n<ul>\n<li>Well, for one, it could be that I installed two versions of Python on my system- possibly, both 32-bit and 64-bit.<\/li>\n<li>The Path variable in my system\u2019s environment variables is probably set to both, but one of them prior to the other- say, the 32-bit.<\/li>\n<li>This made the command prompt use the 32-bit version of pip to install the module I chose.<\/li>\n<li>When I ran the IDLE, I ran the 64-bit version.<\/li>\n<\/ul>\n<p>As this sequence of events unlapped, I couldn\u2019t import the module I just installed.<\/p>\n<p><strong>Q.38. Based on your previous answer, how will you solve this issue?<\/strong><\/p>\n<p>I could do two things.<\/p>\n<ul>\n<li><strong>The temporary solution-<\/strong> I will add the path to sys manually every time I work on a new session of the interpreter.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; sys.path.append('C:\\\\Users\\\\Ayushi\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python37\\\\Scripts')<\/pre>\n<ul>\n<li><strong>The permanent solution-<\/strong> I will update the value of Path in my environment variables to hold the location of the Scripts folder for the 64-bit version first.<\/li>\n<\/ul>\n<p><strong>Q.39. If while installing a package with pip, you get the error No matching installation found, what can you do?<\/strong><\/p>\n<p>In such a situation, one thing I can do is to download the binaries for that package from the following location:<\/p>\n<p><strong>https:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/<\/strong><\/p>\n<p>Then, I can install the wheel using pip.<\/p>\n<p><em><strong>Learn everything about <a href=\"https:\/\/data-flair.training\/blogs\/python-packages\/\">Python Package<\/a><\/strong><\/em><\/p>\n<p><strong>Q.40. How can you keep track of different versions of code?<\/strong><\/p>\n<p>To make this happen, we implement version control. For this, one tool you can use is Git.<\/p>\n<p><strong>Q.41. How do you debug a program in Python? Answer in brief.<\/strong><\/p>\n<p>To debug a Python program, we use the pdb module. This is the <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-debugger\/\">Python debugger.<\/a><\/strong><\/em>\u00a0If we start a program using pdb, it will let us step through the code.<\/p>\n<h3>Python OOPS and Library Interview Questions<\/h3>\n<p><strong>Q.42. Can I dynamically load a module in Python?<\/strong><\/p>\n<p>Dynamic loading is where we do not load a module till we need it. This is slow, but lets us utilize the memory more efficiently. In Python, you can use the importlib module for this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import importlib\r\nmodule = importlib.import_module('my_package.my_module')<\/pre>\n<p><strong>Q.43. Which methods\/functions do we use to determine the type of instance and inheritance?<\/strong><\/p>\n<p>Here, we talk about three methods\/functions- type(), isinstance(), and issubclass().<\/p>\n<p><strong>a. type()<\/strong><\/p>\n<p>This tells us the type of object we\u2019re working with.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(3)<\/pre>\n<p>&lt;class \u2018int\u2019&gt;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(False)<\/pre>\n<p><strong>&lt;class \u2018bool\u2019&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(lambda :print(\"Hi\"))<\/pre>\n<p><strong>&lt;class \u2018function\u2019&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(type)<\/pre>\n<p><strong>&lt;class \u2018type\u2019&gt;<\/strong><\/p>\n<p><strong>b. isinstance()<\/strong><\/p>\n<p>This takes in two arguments- a value and a type. If the value is of the kind of the specified type, it returns True. Else, it returns False.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; isinstance(3,int)<\/pre>\n<p><strong>True<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; isinstance((1),tuple)<\/pre>\n<p><strong>False<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; isinstance((1,),tuple)<\/pre>\n<p><strong>True<\/strong><\/p>\n<p><strong>c. issubclass()<\/strong><\/p>\n<p>This takes two classes as <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-function-arguments\/\">arguments<\/a><\/strong><\/em>. If the first one inherits from the second, it returns True. Else, it returns False.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; class A: pass\r\n&gt;&gt;&gt; class B(A): pass\r\n&gt;&gt;&gt; issubclass(B,A)<\/pre>\n<p><strong>True<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; issubclass(A,B)<\/pre>\n<p><strong>False<\/strong><\/p>\n<p><strong>Q.44. Are methods and constructors the same thing?<\/strong><\/p>\n<p>No, there are subtle but considerable differences-<\/p>\n<ul>\n<li>We must name a constructor in the name of the class; a method name can be anything.<\/li>\n<li>Whenever we create an object, it executes a constructor; whenever we call a method, it executes a method.<\/li>\n<li>For one object, a constructor executes only once; a method can execute any number of times for one object.<\/li>\n<li>We use constructors to define and initialize non-static variables; we use methods to represent business logic to perform operations.<\/li>\n<\/ul>\n<p><strong>Q.45. What is a Python module?<\/strong><\/p>\n<p>A module is a script in Python that defines import statements, functions, classes, and variables. It also holds runnable Python code. ZIP files and DLL files can be modules too. The module holds its name as a string that is in a global variable.<\/p>\n<p><strong>Q.46. What are the file-related modules we have in Python?<\/strong><\/p>\n<p>We have the following libraries and modules that let us manipulate text and binary files on our file systems-<\/p>\n<p><strong>os<\/strong><br \/>\n<strong>os.path<\/strong><br \/>\n<strong>shutil<\/strong><\/p>\n<p><strong>Q.47. Explain, in brief, the uses of the modules sqlite3, ctypes, pickle, traceback, and itertools.<\/strong><\/p>\n<ul>\n<li>sqlite3- Helps with handling databases of type SQLite<\/li>\n<li>ctypes- Lets create and manipulate C data types in Python<\/li>\n<li>pickle- Lets put any data structure to external files<\/li>\n<li>traceback- Allows extraction, formatting, and printing of stack traces<\/li>\n<li>itertools\u2013 Supports working with permutations, combinations, and other useful iterables.<\/li>\n<\/ul>\n<p><strong>Q.48. Explain inheritance in Python.<\/strong><\/p>\n<p>When one class inherits from another, it is said to be the child\/derived\/sub class inheriting from the parent\/base\/super class. It inherits\/gains all members (attributes and methods).<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-70442\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance.png\" alt=\"Python Interview Questions - inheritance\" width=\"527\" height=\"264\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance.png 1060w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance-150x75.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance-300x150.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance-768x385.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance-1024x513.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/Python-Interview-Questions-inheritance-520x260.png 520w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/p>\n<p>Inheritance lets us reuse our code, and also makes it easier to create and maintain applications. Python supports the following kinds of inheritance:<\/p>\n<ul>\n<li>Single Inheritance- A class inherits from a single base class.<\/li>\n<li>Multiple Inheritance- A class inherits from multiple base classes.<\/li>\n<li>Multilevel Inheritance- A class inherits from a base class, which, in turn, inherits from another base class.<\/li>\n<li>Hierarchical Inheritance- Multiple classes inherit from a single base class.<\/li>\n<li>Hybrid Inheritance- Hybrid inheritance is a combination of two or more types of inheritance.<\/li>\n<\/ul>\n<h3>Technical Python Interview Questions and Answers<\/h3>\n<p>Here comes the most important category that is technical Python Interview Questions and Answers &#8211;<\/p>\n<p><strong>Q.49. Explain memory management in Python.<\/strong><\/p>\n<p>Objects and data structures in Python lie on a private heap. The Python memory manager internally manages this. It delegates some work to object-specific allocators while ensuring they operate only within the private heap. Actually, the interpreter manages this heap; the user has no control over it- not even if they manipulate object pointers to memory blocks inside the heap. The Python memory manager allocates heap space to objects and other internal buffers on demand.<\/p>\n<p><strong>Q.50. Write Python logic to count the number of capital letters in a file.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import os\r\n&gt;&gt;&gt; os.chdir('C:\\\\Users\\\\lifei\\\\Desktop')\r\n&gt;&gt;&gt; with open('Today.txt') as today:\r\n    count=0\r\n    for i in today.read():\r\n        if i.isupper():\r\n            count+=1\r\n    print(count)<\/pre>\n<p><strong>26<\/strong><\/p>\n<p><strong>Q.51. How would you make a Python script executable on Unix?<\/strong><\/p>\n<p>For this to happen, two conditions must be met:<\/p>\n<ul>\n<li>The script file\u2019s mode must be executable<\/li>\n<li>The first line must begin with a hash(#). An example of this will be: #!\/usr\/local\/bin\/python<\/li>\n<\/ul>\n<p><strong>Q.52. What functions or methods will you use to delete a file in Python?<\/strong><\/p>\n<p>For this, we may use remove() or unlink().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import os\r\n&gt;&gt;&gt; os.chdir('C:\\\\Users\\\\lifei\\\\Desktop')\r\n&gt;&gt;&gt; os.remove('try.py')\r\n&gt;&gt;&gt;<\/pre>\n<p>When we go and check our Desktop, the file is gone. Let\u2019s go make it again so we can delete it again using unlink().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; os.unlink('try.py')\r\n&gt;&gt;&gt;<\/pre>\n<p>Both functions are the same, but unlink is the traditional Unix name for it.<\/p>\n<p><strong>Q.53. Can you write a function to generate the following pyramid?<\/strong><\/p>\n<p><span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0*<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0***<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0\u00a0*****<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0*******<\/span><\/p>\n<p><span style=\"font-weight: 400\">*********<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def pyramid(n):\r\n  for row in range(n):\r\n    for space in range(n-row):\r\n      print(' ',end='')\r\n    for star in range(row):\r\n      print('*',end='')\r\n    for star in range(row+1):\r\n      print('*',end='')\r\n    print()\r\n\r\npyramid(5)<\/pre>\n<p><strong>Q.54.\u00a0How will you print the contents of a file?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; try:\r\n      with open('tabs.txt','r') as f:\r\n             print(f.read())\r\nexcept IOError:\r\n      print(\"File not found\")<\/pre>\n<h3>Advanced Python Interview Questions<\/h3>\n<p><strong>Q.55.\u00a0Explain lambda expressions. When would you use one?<\/strong><\/p>\n<p>When we want a function with a single expression, we can define it anonymously. A <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-lambda-expressions\/\">lambda expression<\/a><\/strong><\/em> may take input and returns a value. To define the above function as a lambda expression, we type the following code in the interpreter:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; (lambda a,b:a if a&gt;b else b)(3,3.5)<\/pre>\n<p><strong>3.5<\/strong><\/p>\n<p>Here, a and b are the inputs. a if a&gt;b else b is the expression to return. The arguments are 3 and 3.5.<\/p>\n<p>It is possible to not have any inputs here.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; (lambda :print(\"Hi\"))()<\/pre>\n<p><strong>Hi<\/strong><\/p>\n<p><strong>Q.56. What is a generator?<\/strong><\/p>\n<p>Python generator produces a sequence of values to iterate on. This way, it is kind of an iterable.<br \/>\nWe define a function that \u2018yields\u2019 values one by one, and then use a for loop to iterate on it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; def squares(n):\r\ni=1\r\nwhile(i&lt;=n):\r\nyield i**2\r\ni+=1\r\n&gt;&gt;&gt; for i in squares(7):\r\nprint(i)<\/pre>\n<p><strong>1<\/strong><br \/>\n<strong>4<\/strong><br \/>\n<strong>9<\/strong><br \/>\n<strong>16<\/strong><br \/>\n<strong>25<\/strong><br \/>\n<strong>36<\/strong><br \/>\n<strong>49<\/strong><\/p>\n<p><strong>Q.57. So, what is an iterator, then?<\/strong><\/p>\n<p>An iterator returns one object at a time to iterate on. To create an iterator, we use the iter() function.<\/p>\n<p><strong>odds=iter([1,3,5,7,9])<\/strong><\/p>\n<p>Then, we call the next() function on it every time we want an object.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>1<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>3<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>5<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>7<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>9<\/strong><\/p>\n<p>And now, when we call it again, it raises a StopIteration exception. This is because it has reached the end of the values to iterate on.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; next(odds)<\/pre>\n<p><strong>Traceback (most recent call last):<\/strong><br \/>\n<strong>File \u201c&lt;pyshell#295&gt;\u201d, line 1, in &lt;module&gt;<\/strong><br \/>\n<strong>next(odds)<\/strong><br \/>\n<strong>StopIteration<\/strong><\/p>\n<p><strong>Q.58. Okay, we asked you about generators and iterators, and you gave us the right answers. But don\u2019t they sound similar?<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-70430\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators.png\" alt=\"python scripting interview questions\" width=\"379\" height=\"146\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators.png 582w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators-150x58.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators-300x115.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-generators-vs-iterators-520x200.png 520w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/a><\/p>\n<p>They do, but there are subtle differences:<\/p>\n<ul>\n<li>For a generator, we create a function. For an iterator, we use in-built functions iter() and next().<\/li>\n<li>For a generator, we use the keyword \u2018yield\u2019 to yield\/return an object at a time.<\/li>\n<li>A generator may have as many \u2018yield\u2019 statements as you want.<\/li>\n<li>A generator will save the states of the local variables every time \u2018yield\u2019 will pause the loop. An iterator does not use local variables; it only needs an iterable to iterate on.<\/li>\n<li>Using a class, you can implement your own iterator, but not a generator.<\/li>\n<li>Generators are fast, compact, and simpler.<\/li>\n<li>Iterators are more memory-efficient.<\/li>\n<\/ul>\n<p><strong>Q.59. What is a decorator?<\/strong><\/p>\n<p>A decorator is a function that adds functionality to another function without modifying it. It wraps another function to add functionality to it. Take an example.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; def decor(func):\r\n   def wrap():\r\n       print(\"$$$$$$$$$$$$$$$$$\")\r\n       func()\r\n       print(\"$$$$$$$$$$$$$$$$$\")<\/pre>\n<p><strong>return wrap<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; @decor\r\ndef sayhi():\r\n   print(\"Hi\")\r\n&gt;&gt;&gt; sayhi()<\/pre>\n<p><strong>$$$$$$$$$$$$$$$$$<\/strong><br \/>\n<strong>Hi<\/strong><br \/>\n<strong>$$$$$$$$$$$$$$$$$<\/strong><\/p>\n<p>Decorators are an example of metaprogramming, where one part of the code tries to change another.<\/p>\n<p><strong>Q.60. What is Monkey Patching?<\/strong><\/p>\n<p>Monkey patching refers to modifying a class or module at runtime (dynamic modification). It extends Python code at runtime.<\/p>\n<p><strong>For example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">from pkg.module import MyClass\r\ndef sayhello(self):\r\n       print(\"Hello\")\r\n\r\nMyClass.sayhello=sayhello<\/pre>\n<p><em><strong>Wait!! You should check the <a href=\"https:\/\/data-flair.training\/blogs\/python-career-opportunities\/\">career opportunities in Python<\/a>.\u00a0\u00a0<\/strong><\/em><\/p>\n<p>Hope you have enjoyed the above Python Interview Questions, but this is not the end. You need to practice some open-ended or behavior-based interview questions to crack your next Python Interview.<\/p>\n<h3>Open-ended Interview Questions<\/h3>\n<p><strong>Q.61.<\/strong>\u00a0Why should we hire you?<\/p>\n<p><strong>Q.62.<\/strong> What personal growth did you see in yourself after your last job?<\/p>\n<p><strong>Q.63.<\/strong> Tell me about a situation you found yourself stuck in your previous job. How did you work your way out?<\/p>\n<p><strong>Q.64.<\/strong>\u00a0How would you resolve a dispute with a colleague? Did you face such a situation in your previous job?<\/p>\n<p><strong>Q.65.\u00a0<\/strong>What do you expect us to do better than your previous employer?<\/p>\n<p><strong>Q.66.<\/strong>\u00a0Have you ever changed someone&#8217;s opinion at work?<\/p>\n<p><strong>Q.67.<\/strong>\u00a0What are your thoughts on office gossips?<\/p>\n<p><strong>Q.68.<\/strong>\u00a0What would be the weakest link to your performance?<\/p>\n<p><strong>Q.69.\u00a0<\/strong>Where do you think the industry is going in the next 15 years?<\/p>\n<p><strong>Q.70.\u00a0<\/strong>What legacy did you leave in your previous job? Did you develop an innovative solution?<\/p>\n<p><strong>Q.71.<\/strong>\u00a0Would you prefer working alone, or in a small\/large team?<\/p>\n<p>Try to answer the above questions by yourself. If you need any help, comment below.<\/p>\n<p style=\"text-align: center\"><em>Have you developed any Project in Python yet? If not, then first you need to practice<strong> <a href=\"https:\/\/data-flair.training\/blogs\/python-projects-with-source-code\/\">top Python Projects with their source code<\/a><\/strong>. Once you are done with this, refer to the last part of Python Interview Question and Answer Series (link at the top)<\/em><\/p>\n<p>If this helped you, thank me through the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to the second part of DataFlair&#8217;s Python Interview Questions and Answer Series. If you are the first time visitor then you must take a quick look at the series &#8211; Python Interview Questions&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":70441,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[10384,10425,10493,10611,10612,10825],"class_list":["post-70268","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-basic-interview-questions","tag-python-coding-interview-questions","tag-python-developer-interview-questions","tag-python-interview-questions","tag-python-interview-questions-and-answers","tag-python-scripting-interview-questions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>71 Python Interview Questions and Answers [New] - Get Ready for Technical Round - DataFlair<\/title>\n<meta name=\"description\" content=\"71 Python Interview Questions and Answers in different categories. Explore technical,basic, advanced,library,framework based interview questions for Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-interview-questions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"71 Python Interview Questions and Answers [New] - Get Ready for Technical Round - DataFlair\" \/>\n<meta property=\"og:description\" content=\"71 Python Interview Questions and Answers in different categories. Explore technical,basic, advanced,library,framework based interview questions for Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-interview-questions\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-03T04:29:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-04T03:59:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"71 Python Interview Questions and Answers [New] - Get Ready for Technical Round - DataFlair","description":"71 Python Interview Questions and Answers in different categories. Explore technical,basic, advanced,library,framework based interview questions for Python","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:\/\/data-flair.training\/blogs\/python-interview-questions\/","og_locale":"en_US","og_type":"article","og_title":"71 Python Interview Questions and Answers [New] - Get Ready for Technical Round - DataFlair","og_description":"71 Python Interview Questions and Answers in different categories. Explore technical,basic, advanced,library,framework based interview questions for Python","og_url":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-10-03T04:29:11+00:00","article_modified_time":"2019-10-04T03:59:14+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"71 Python Interview Questions and Answers [New] &#8211; Get Ready for Technical Round","datePublished":"2019-10-03T04:29:11+00:00","dateModified":"2019-10-04T03:59:14+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/"},"wordCount":3829,"commentCount":15,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg","keywords":["python basic interview questions","python coding interview questions","python developer interview questions","python interview questions","python interview questions and answers","python scripting interview questions"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-interview-questions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/","url":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/","name":"71 Python Interview Questions and Answers [New] - Get Ready for Technical Round - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg","datePublished":"2019-10-03T04:29:11+00:00","dateModified":"2019-10-04T03:59:14+00:00","description":"71 Python Interview Questions and Answers in different categories. Explore technical,basic, advanced,library,framework based interview questions for Python","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-interview-questions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/09\/python-interview-questions-.jpg","width":802,"height":420,"caption":"python interview questions"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-interview-questions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"71 Python Interview Questions and Answers [New] &#8211; Get Ready for Technical Round"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/70268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=70268"}],"version-history":[{"count":14,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/70268\/revisions"}],"predecessor-version":[{"id":70682,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/70268\/revisions\/70682"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/70441"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=70268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=70268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=70268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}