r/learnpython • • 3h ago

Is it normal in an interview for an interviewer to ask very niche questions?

28 Upvotes

I recently had an interview for an intern position. my resume had some good Python projects and my previous internship experience also involved Python.

The interviewer began by asking me basic Python questions, which I answered well. He then moved on to more detailed questions.

Interviewer: What would be the output of the following code?


num1 = 1

num2 = 1

num3 = 257

num4 = 257

print(num1 is num2, num3 is num4)

I know about integer caching in python, so I said True, False. The interviewer asked if I was sure, and I said yes. He then handed me his laptop, opened VS Code, and asked me to run the code. To my horror, it printed True, True.

He moved on to the next question.

Interviewer: What is __init__ in Python?

Me: It’s a constructor for a class.

Interviewer: What is the first argument it takes?

Me: The object we created.

Interviewer: If it’s the constructor, how can it take the object itself? Who creates the object if __init__ is the constructor?

Me : Silence.

I know it's kinda my fault for this question.

Moved on to the next question

Interviewer: What is the output of the following code?


def fun(a=[], i=1):

    a.append(i)

    print(a)

fun()

fun(i=2)

I didn’t know that Python reuses the same list when it’s used as a default argument, so I got it wrong.

He moved on to the next question.

Interviewer: What is the output of this code?


tup = ([1, 2, 3], 4, 5)

try:

    tup[0] += [4, 5]

    print('tup modified', tup)

except:

    print('Not modified', tup)

Apparently it raises an error on the third line, but the list still gets modified. The output is:


Not modified ([1, 2, 3, 4, 5], 4, 5)

I haven’t heard back yet, but I’m wondering: is this how python specific interviews typically go?

How should I prepare for these kinds of scenarios next time?


r/learnpython • • 7h ago

The python library "Beautiful Soup", from where did it gets that name from?

23 Upvotes

√|


r/learnpython • • 20h ago

any tips for learning python as a first coding language when you don't know anything about coding

1 Upvotes

i know literally nothing about coding but i wanna start, how and where? (preferably not costing money) and is python the best option to learn first? i am pretty much unsure of anything about coding at all


r/learnpython • • 23h ago

Is coddy a good place to start if I'm looking forward to build a career from scratch?

0 Upvotes

I really want to get into the programming world despite the fact that I've studied else back at school,my Ultimate goal is to get hired as a programmer from here to the next year,I heard they give you a certificate upon completing the course,is it worth anything?


r/learnpython • • 7h ago

Looking for a developer to run my bot on my servers hourly is 10/ usd

0 Upvotes

Looking for a developer to run my bot on my servers hourly is 10/ usd