Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28459 > unrolled thread

Re: Python Interview Questions

Started bycharvigroups@gmail.com
First post2012-09-04 23:50 -0700
Last post2012-09-06 12:38 +0100
Articles 15 — 8 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python Interview Questions charvigroups@gmail.com - 2012-09-04 23:50 -0700
    Re: Python Interview Questions Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-09-05 14:10 +0530
    Re: Python Interview Questions Peter Otten <__peter__@web.de> - 2012-09-05 16:21 +0200
    Re: Python Interview Questions Chris Angelico <rosuav@gmail.com> - 2012-09-06 00:34 +1000
    Re: Python Interview Questions Chris Angelico <rosuav@gmail.com> - 2012-09-06 00:36 +1000
    Re: Python Interview Questions Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-05 09:22 -0600
      Re: Python Interview Questions Roy Smith <roy@panix.com> - 2012-09-05 12:38 -0400
    Re: Python Interview Questions Chris Angelico <rosuav@gmail.com> - 2012-09-06 01:34 +1000
    Re: Python Interview Questions Dave Angel <d@davea.name> - 2012-09-05 12:01 -0400
    Re: Python Interview Questions Roy Smith <roy@panix.com> - 2012-09-05 12:11 -0400
    Re: Python Interview Questions Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-05 10:40 -0600
      Re: Python Interview Questions Roy Smith <roy@panix.com> - 2012-09-05 12:45 -0400
    Re: Python Interview Questions Chris Angelico <rosuav@gmail.com> - 2012-09-06 08:13 +1000
    Re: Python Interview Questions Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-09-06 09:54 +0530
    Re: Python Interview Questions MRAB <python@mrabarnett.plus.com> - 2012-09-06 12:38 +0100

#28459 — Re: Python Interview Questions

Fromcharvigroups@gmail.com
Date2012-09-04 23:50 -0700
SubjectRe: Python Interview Questions
Message-ID<d4e47e64-91d3-4b9f-9e98-4985cd8cb936@googlegroups.com>
Hi Guys,

Finally I have decided to put best interview question and answers.

Please visit http://www.f2finterview.com/web/CorePython/ for core python and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python

On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote:
> Hi,
> 
> I have used Python for a couple of projects last year and I found it
> extremely useful. I could write two middle size projects in 2-3 months
> (part time). Right now I am a bit rusty and trying to catch up again
> with Python.
> 
> I am now appearing for Job Interviews these days and I am wondering if
> anybody of you appeared for a Python Interview. Can you please share
> the questions you were asked. That will be great help to me.
> 
> Thanks,

[toc] | [next] | [standalone]


#28467

FromKushal Kumaran <kushal.kumaran+python@gmail.com>
Date2012-09-05 14:10 +0530
Message-ID<mailman.223.1346834815.27098.python-list@python.org>
In reply to#28459
On Wed, Sep 5, 2012 at 12:20 PM,  <charvigroups@gmail.com> wrote:
> On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote:
>> Hi,
>>
>> I have used Python for a couple of projects last year and I found it
>> extremely useful. I could write two middle size projects in 2-3 months
>> (part time). Right now I am a bit rusty and trying to catch up again
>> with Python.
>>
>> I am now appearing for Job Interviews these days and I am wondering if
>> anybody of you appeared for a Python Interview. Can you please share
>> the questions you were asked. That will be great help to me.
>>
>
> Finally I have decided to put best interview question and answers.
>
> Please visit http://www.f2finterview.com/web/CorePython/ for core python and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python
>

As I see from a quick glance, several of your answers seem to be
copied from the python faq at http://docs.python.org/faq/.  The
copyright notice for the python.org website seems to be at
http://docs.python.org/copyright.html.  Do you have the Python
Software Foundation's permission to copy large chunks of the
python.org website and claim it as your own content?

-- 
regards,
kushal

[toc] | [prev] | [next] | [standalone]


#28499

FromPeter Otten <__peter__@web.de>
Date2012-09-05 16:21 +0200
Message-ID<mailman.240.1346854897.27098.python-list@python.org>
In reply to#28459
charvigroups@gmail.com wrote:

> Finally I have decided to put best interview question and answers.
> 
> Please visit http://***/web/CorePython/ for core python
> and http://***/web/PythonAdvanced/ for advanced python

Hm, are you a reformed PHP programmer who has never heard of sql injection 
attacks? The first "advanced" answer (and probably all the database-related 
stuff) should definitely be withdrawn.

[toc] | [prev] | [next] | [standalone]


#28502

FromChris Angelico <rosuav@gmail.com>
Date2012-09-06 00:34 +1000
Message-ID<mailman.242.1346855687.27098.python-list@python.org>
In reply to#28459
On Thu, Sep 6, 2012 at 12:21 AM, Peter Otten <__peter__@web.de> wrote:
> charvigroups@gmail.com wrote:
>
>> Finally I have decided to put best interview question and answers.
>>
>> Please visit http://***/web/CorePython/ for core python
>> and http://***/web/PythonAdvanced/ for advanced python
>
> Hm, are you a reformed PHP programmer who has never heard of sql injection
> attacks? The first "advanced" answer (and probably all the database-related
> stuff) should definitely be withdrawn.

I wouldn't go that far. The 'name' parameter, I would expect, would be
a constant. However, this strikes me as encouraging some really
inefficient code, like iterating over all the rows in a table with N+1
queries (one to get the length, then a separate query for each row).
Plus, use of limit without order by is not guaranteed (although since
this is specific to MySQL, it's unlikely you'll run into trouble - but
PostgreSQL, with its MVCC storage system, frequently reorders rows in
a table).

As a general rule, I don't like SQL builders. I'd prefer to directly
embed SQL statements in my code. Although sometimes a class can
helpfully manage some things, it's seldom worth having something that
tries to pretend a table is iterable in that sort of way.

ChrisA

[toc] | [prev] | [next] | [standalone]


#28503

FromChris Angelico <rosuav@gmail.com>
Date2012-09-06 00:36 +1000
Message-ID<mailman.243.1346855813.27098.python-list@python.org>
In reply to#28459
On Thu, Sep 6, 2012 at 12:34 AM, Chris Angelico <rosuav@gmail.com> wrote:
> However, this strikes me as encouraging some really
> inefficient code, like iterating over all the rows in a table with N+1
> queries (one to get the length, then a separate query for each row).

Huh. And then I scroll down, and that's precisely what he's doing. Do
you understand why this is a bad thing to do?

ChrisA

[toc] | [prev] | [next] | [standalone]


#28507

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-09-05 09:22 -0600
Message-ID<mailman.245.1346858610.27098.python-list@python.org>
In reply to#28459
On Wed, Sep 5, 2012 at 8:34 AM, Chris Angelico <rosuav@gmail.com> wrote:
> I wouldn't go that far. The 'name' parameter, I would expect, would be
> a constant.

The 'item' parameter, though, is probably not a constant, and it's
interpolated just the same.

> However, this strikes me as encouraging some really
> inefficient code, like iterating over all the rows in a table with N+1
> queries (one to get the length, then a separate query for each row).
> Plus, use of limit without order by is not guaranteed (although since
> this is specific to MySQL, it's unlikely you'll run into trouble - but
> PostgreSQL, with its MVCC storage system, frequently reorders rows in
> a table).

The lack of an ORDER BY is the least of the problems with that SQL.
He's also using LIMIT without OFFSET, so the only thing that the
'item' argument changes is how many rows are returned (all but one of
which are ignored), not which one is actually fetched.

It's a bit sad that these are touted as answers to interview
questions.  I wouldn't hire anybody who gave answers like these.

[toc] | [prev] | [next] | [standalone]


#28522

FromRoy Smith <roy@panix.com>
Date2012-09-05 12:38 -0400
Message-ID<roy-C27BFC.12380305092012@news.panix.com>
In reply to#28507
In article <mailman.245.1346858610.27098.python-list@python.org>,
 Ian Kelly <ian.g.kelly@gmail.com> wrote:

> It's a bit sad that these are touted as answers to interview
> questions.  I wouldn't hire anybody who gave answers like these.

Over time, I've become convinced that most interview questions are crap.  
The best programming interview questions always start with, "write a 
program ...".

[toc] | [prev] | [next] | [standalone]


#28508

FromChris Angelico <rosuav@gmail.com>
Date2012-09-06 01:34 +1000
Message-ID<mailman.246.1346859281.27098.python-list@python.org>
In reply to#28459
On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> The lack of an ORDER BY is the least of the problems with that SQL.
> He's also using LIMIT without OFFSET, so the only thing that the
> 'item' argument changes is how many rows are returned (all but one of
> which are ignored), not which one is actually fetched.

No, he's using the two-arg form of LIMIT.

> It's a bit sad that these are touted as answers to interview
> questions.  I wouldn't hire anybody who gave answers like these.

The code does not work as posted; there are args missing from the
INSERT example, for, uhh, example. It makes it hard to evaluate the
quality of the code, in some places. I'm not sure what these posts are
supposed to be, but I hope they're not being held up as model answers
to interview questions. For a start, I can't find any sort of clear
questions.

Or is the code itself the question and "How would you improve this"?

ChrisA

[toc] | [prev] | [next] | [standalone]


#28515

FromDave Angel <d@davea.name>
Date2012-09-05 12:01 -0400
Message-ID<mailman.250.1346860897.27098.python-list@python.org>
In reply to#28459
On 09/05/2012 11:34 AM, Chris Angelico wrote:
> On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> The lack of an ORDER BY is the least of the problems with that SQL.
>> He's also using LIMIT without OFFSET, so the only thing that the
>> 'item' argument changes is how many rows are returned (all but one of
>> which are ignored), not which one is actually fetched.
> No, he's using the two-arg form of LIMIT.
>
>> It's a bit sad that these are touted as answers to interview
>> questions.  I wouldn't hire anybody who gave answers like these.
> The code does not work as posted; there are args missing from the
> INSERT example, for, uhh, example. It makes it hard to evaluate the
> quality of the code, in some places. I'm not sure what these posts are
> supposed to be, but I hope they're not being held up as model answers
> to interview questions. For a start, I can't find any sort of clear
> questions.
>
> Or is the code itself the question and "How would you improve this"?
>
> ChrisA

Skip ahead to about page 13 to get more traditional questions,  There,
many of the simplest questions have invalid answers, or confusing
explanations.

For example, on page 15, the question that says " ... if a list of words
is empty..."   uses     a=""   as its source data to test with.

The first question on page 16 forgets to construct a loop, thus
processing only the first line in the file.

page 18 introduces new syntax to the language:
     print n+=1  ##will work

and reassures us in the comment that it will work !!

page 18 also claims that values are passed to function by value.





-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#28518

FromRoy Smith <roy@panix.com>
Date2012-09-05 12:11 -0400
Message-ID<roy-A94EA7.12111005092012@news.panix.com>
In reply to#28459
In article <d4e47e64-91d3-4b9f-9e98-4985cd8cb936@googlegroups.com>,
 charvigroups@gmail.com wrote:

> Hi Guys,
> 
> Finally I have decided to put best interview question and answers.
> 
> Please visit http://www.f2finterview.com/web/CorePython/ for core python and 
> http://www.f2finterview.com/web/PythonAdvanced/ for advanced python

I was going to comment on some of the specific items, but I got hung up 
being unable to copy-paste text from your site so I could quote it.  
That's usually done with some variation on "user-select: none" in the 
CSS, but I didn't see that.  I'm assuming it's some javascript trickery.

Why do you do that?  It degrades the usability of the site, and doesn't 
provide any real protection against people stealing content.

[toc] | [prev] | [next] | [standalone]


#28523

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-09-05 10:40 -0600
Message-ID<mailman.255.1346863293.27098.python-list@python.org>
In reply to#28459
On Wed, Sep 5, 2012 at 9:34 AM, Chris Angelico <rosuav@gmail.com> wrote:
> On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> The lack of an ORDER BY is the least of the problems with that SQL.
>> He's also using LIMIT without OFFSET, so the only thing that the
>> 'item' argument changes is how many rows are returned (all but one of
>> which are ignored), not which one is actually fetched.
>
> No, he's using the two-arg form of LIMIT.

My mistake.  I didn't even know there was a two-arg form of LIMIT.
Must be a MySQL thing. :-)

Cheers,
Ian

[toc] | [prev] | [next] | [standalone]


#28524

FromRoy Smith <roy@panix.com>
Date2012-09-05 12:45 -0400
Message-ID<roy-748754.12454705092012@news.panix.com>
In reply to#28523
In article <mailman.255.1346863293.27098.python-list@python.org>,
 Ian Kelly <ian.g.kelly@gmail.com> wrote:

> My mistake.  I didn't even know there was a two-arg form of LIMIT.
> Must be a MySQL thing. :-)

What are you talking about?  SQL is an ISO Standard.  Therefore, all 
implementations work the same way.  Didn't you get the memo?

[toc] | [prev] | [next] | [standalone]


#28543

FromChris Angelico <rosuav@gmail.com>
Date2012-09-06 08:13 +1000
Message-ID<mailman.271.1346883227.27098.python-list@python.org>
In reply to#28459
On Thu, Sep 6, 2012 at 2:40 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Wed, Sep 5, 2012 at 9:34 AM, Chris Angelico <rosuav@gmail.com> wrote:
>> On Thu, Sep 6, 2012 at 1:22 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>>> The lack of an ORDER BY is the least of the problems with that SQL.
>>> He's also using LIMIT without OFFSET, so the only thing that the
>>> 'item' argument changes is how many rows are returned (all but one of
>>> which are ignored), not which one is actually fetched.
>>
>> No, he's using the two-arg form of LIMIT.
>
> My mistake.  I didn't even know there was a two-arg form of LIMIT.
> Must be a MySQL thing. :-)

Yeah, it's not something I've used, but when my current job started,
we were using MySQL and I used to eyeball the logs to see what queries
were performing most suboptimally. (There were some pretty egregious
ones. Most memorable was rewriting a TEXT field several times a second
with several KB of PHP serialized array with status/statistical
information. Structured information, yes. Stored as a clob.) My first
databasing experience was DB2, with the uber-verbose "FETCH FIRST n
ROW[S] ONLY", but now I'm happily on Postgres.

Everyone who wants to use LIMIT without ORDER BY should try their code
on Postgres. You'll quickly discover the problem.

ChrisA

[toc] | [prev] | [next] | [standalone]


#28548

FromKushal Kumaran <kushal.kumaran+python@gmail.com>
Date2012-09-06 09:54 +0530
Message-ID<mailman.276.1346905858.27098.python-list@python.org>
In reply to#28459
On Wed, Sep 5, 2012 at 3:11 PM, Stephen Anto <charvigroups@gmail.com> wrote:
> On Wed, Sep 5, 2012 at 2:10 PM, Kushal Kumaran
> <kushal.kumaran+python@gmail.com> wrote:
>>
>> On Wed, Sep 5, 2012 at 12:20 PM,  <charvigroups@gmail.com> wrote:
>> > On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote:
>> >> Hi,
>> >>
>> >> I have used Python for a couple of projects last year and I found it
>> >> extremely useful. I could write two middle size projects in 2-3 months
>> >> (part time). Right now I am a bit rusty and trying to catch up again
>> >> with Python.
>> >>
>> >> I am now appearing for Job Interviews these days and I am wondering if
>> >> anybody of you appeared for a Python Interview. Can you please share
>> >> the questions you were asked. That will be great help to me.
>> >>
>> >
>> > Finally I have decided to put best interview question and answers.
>> >
>> > Please visit http://www.f2finterview.com/web/CorePython/ for core python
>> > and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python
>> >
>>
>> As I see from a quick glance, several of your answers seem to be
>> copied from the python faq at http://docs.python.org/faq/.  The
>> copyright notice for the python.org website seems to be at
>> http://docs.python.org/copyright.html.  Do you have the Python
>> Software Foundation's permission to copy large chunks of the
>> python.org website and claim it as your own content?
>>
>
> Thank you for your information, I really sorry for this, if possible could
> you note which are the questions taken from faq, we will remove it as early
> as possible.
>

Since your website's Terms of Use state that you own the content, it
is your problem to make sure whatever's there is there legally.

Here's one example, though, to get you started: See the entry "Why
can’t I use an assignment in an expression?" at
http://docs.python.org/faq/design.html, and compare with the content
under the identical heading on page 3 of the CorePython section.

-- 
regards,
kushal

[toc] | [prev] | [next] | [standalone]


#28577

FromMRAB <python@mrabarnett.plus.com>
Date2012-09-06 12:38 +0100
Message-ID<mailman.294.1346931533.27098.python-list@python.org>
In reply to#28459
On 06/09/2012 05:24, Kushal Kumaran wrote:
> On Wed, Sep 5, 2012 at 3:11 PM, Stephen Anto <charvigroups@gmail.com> wrote:
>> On Wed, Sep 5, 2012 at 2:10 PM, Kushal Kumaran
>> <kushal.kumaran+python@gmail.com> wrote:
>>>
>>> On Wed, Sep 5, 2012 at 12:20 PM,  <charvigroups@gmail.com> wrote:
>>> > On Tuesday, October 30, 2007 11:44:01 PM UTC+5:30, Krypto wrote:
>>> >> Hi,
>>> >>
>>> >> I have used Python for a couple of projects last year and I found it
>>> >> extremely useful. I could write two middle size projects in 2-3 months
>>> >> (part time). Right now I am a bit rusty and trying to catch up again
>>> >> with Python.
>>> >>
>>> >> I am now appearing for Job Interviews these days and I am wondering if
>>> >> anybody of you appeared for a Python Interview. Can you please share
>>> >> the questions you were asked. That will be great help to me.
>>> >>
>>> >
>>> > Finally I have decided to put best interview question and answers.
>>> >
>>> > Please visit http://www.f2finterview.com/web/CorePython/ for core python
>>> > and http://www.f2finterview.com/web/PythonAdvanced/ for advanced python
>>> >
>>>
>>> As I see from a quick glance, several of your answers seem to be
>>> copied from the python faq at http://docs.python.org/faq/.  The
>>> copyright notice for the python.org website seems to be at
>>> http://docs.python.org/copyright.html.  Do you have the Python
>>> Software Foundation's permission to copy large chunks of the
>>> python.org website and claim it as your own content?
>>>
>>
>> Thank you for your information, I really sorry for this, if possible could
>> you note which are the questions taken from faq, we will remove it as early
>> as possible.
>>
>
> Since your website's Terms of Use state that you own the content, it
> is your problem to make sure whatever's there is there legally.
>
> Here's one example, though, to get you started: See the entry "Why
> can’t I use an assignment in an expression?" at
> http://docs.python.org/faq/design.html, and compare with the content
> under the identical heading on page 3 of the CorePython section.
>
The section below it comes from here:

http://svn.effbot.org/public/stuff/sandbox/pyfaq/is-there-a-tool-to-help-find-bugs-or-perform-static-analysis.xml

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web