Senin, 20 Maret 2017

5 Most Common Interview Questions asked on Python

1.Question Fill in the missing code: <code class="language-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_directory_contents_data</span><span class="hljs-params">(sPath)</span>:</span> <span class="hljs-string">""" This function takes the names of a directory and print out the path files within that directory as well as any file contained in contained directory. This functions is similar to os.walk. Please don't use os.walk in your answesr. We are interested in your ability to work with nested structure. """</span> fill_this_in </code> Answer <code class="language-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_directory_contents</span><span class="hljs-params">(sPath)</span>:</span> <span class="hljs-keyword">import</span> os <span class="hljs-keyword">for</span> sChild <span class="hljs-keyword">in</span> os.listdir(sPath): sChildPath = os.path.join(sPath,sChild) <span class="hljs-keyword">if</span> os.path.isdir(sChildPath): print_directory_contents(sChildPath) <span class="hljs-keyword">else</span>: print(sChildPath) </code> Why Does This Matter:

The post 5 Most Common Interview Questions asked on Python appeared first on Coding Security.


5 Most Common Interview Questions asked on Python
read more

Tidak ada komentar:

Posting Komentar