Topics | Search Log Out | Register | Edit Profile
Hide Clipart | Banned/Unbanned User Log | Moderator Login History | Thread Delete/Move Log | Last 30 mins | 1 | 2
Python interview questions

Chalanachithram.com DB » New TF Industry Related » Archive through May 10, 2018 » Python interview questions « Previous Next »
Author Message
 

Biggboss
Side Hero
Username: Biggboss

Post Number: 3719
Registered: 08-2017
Posted From: 73.241.241.99

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 08:21 pm:       


Viswamitra:

how can you swap values of a and b without using temporary variable
ans:




a,b = b,a
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 894
Registered: 09-2015
Posted From: 2.30.113.48

Rating: 
Votes: 1 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:17 pm:       

14.

t = (1, 2, [30, 40])
t[2] += [50, 60]
What happens next? Choose the best answer:
a. t becomes (1, 2, [30, 40, 50, 60]).
b. TypeError is raised with the message 'tuple' object does not support item
assignment.
c. Neither.
d. Both a and b.
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 893
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:13 pm:       


Emc2:




i use cPython for projects and for performance consideration use PyPy..
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 892
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:12 pm:       


Nanigadulocal:




try question 9, it has tamanna shivaji in it...:-)
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 891
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:10 pm:       


Nanigadulocal:




swapping can be done in 1000 ways....but pythonic way is what i am taking about...gave it below...
regular way lo kanna if you do in pythonic wy it is considered most...

example reversal of string say

s = "nani"

you can do this in many ways...

pythonic wy is using slicing antey idi

s[::-1]
“Only sheep need a shepherdâ€
 

Emc2
Legend
Username: Emc2

Post Number: 68741
Registered: 03-2008
Posted From: 71.127.33.124

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:04 pm:       

naku jython pedda ga touch ledu, kani sso gluu ki scripting ki task ichi dobbaru..

dev env lo scrp raasi esthe total system lock down, we end up deleting current instance and install the back up..

fire chesthru anukunna emi analedu
 

Nanigadulocal
Side Hero
Username: Nanigadulocal

Post Number: 8059
Registered: 09-2016
Posted From: 63.79.91.18

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:02 pm:       


Viswamitra:

my favourite qtn is 12






enti swapping nums question fav aaaa ...
ippduu desam lo freshers ni kudaa adgadam ledhuu ee question ...
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 890
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:02 pm:       


Whitecollar:




a,b =b,a
simple
this is pythonic way of doing
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 889
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:01 pm:       


Nanigadulocal:



my favourite qtn is 12...power of python annattu...tuple unpacking....
“Only sheep need a shepherdâ€
 

Whitecollar
Hero
Username: Whitecollar

Post Number: 13081
Registered: 03-2016
Posted From: 209.184.52.152

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 06:00 pm:       


Viswamitra:

12.
a = 10
b=20
how can you swap values of a and b without using temporary variable
ans:




a = a+b (value is 30)
b = a-b (30-20 is 10)
a = a-b (30-10 is 20)

Pilla question kada bro
veni.. vidi.. vici..

 

Nanigadulocal
Side Hero
Username: Nanigadulocal

Post Number: 8057
Registered: 09-2016
Posted From: 63.79.91.18

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:58 pm:       


Gatti_gunde:

mana stalker ivvanni pilli bithari kochens




interview ayyakaa entha amandhii booths bobbaroo stalker ni ee quchans kii
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 888
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:56 pm:       

12.
a = 10
b=20
how can you swap values of a and b without using temporary variable
ans:


13. whats the output

a = (1,2,3,4)
b = (10,11,12,)
d = zip(zip(a,),b)
print d
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 887
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:47 pm:       


Gatti_gunde:

asalu position enti inthaki




senior assoc to VP level annai...

first codility exam, tarvaata idi....
“Only sheep need a shepherdâ€
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 886
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:43 pm:       

11.
whats the output

def add_to_input(func):
def wrapper(*args, **kwargs):
kwargs["a"] = 10
return func(*args, **kwargs)
return wrapper

@add_to_input
def add(*args, **kwargs):
print kwargs["a"]

add({"a":1000})
“Only sheep need a shepherdâ€
 

Gatti_gunde
Megastar
Username: Gatti_gunde

Post Number: 23811
Registered: 02-2010
Posted From: 71.127.150.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:36 pm:       


Nanigadulocal:

naa mansuloo maataa .. nuvvu cheppesav bahyatki


daaniki thodu mana stalker ivvanni pilli bithari kochens nenaithe libraries adugutha ani Sivaji operation garuda type lo inkedh talking

Devops position ki libraries ani ante ...bayataki ra ra choochukundhaam ani vachestha
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 885
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:36 pm:       

8

whats the use of ast(Abstract syntax trees) in python ??

9

class Person:

def __init__(self, first, last):
self.firstname = first
self.lastname = last

def __str__(self):
return "This is First Person"
class Person_2:

def __init__(self, first, last):
self.firstname = first
self.lastname = last

def __str__(self):
return "Tamanna shivaji"

class Employee(Person,Person_2):

def __init__(self, first, last):
pass



x = Employee("A","B")
print(x)

whats the output ??? // I mean x

10.
find the numbers from 0 to 999 which are divisible by 23 and then substract 10 from each of the number and then all the remaining numbers...code should be in a single line...
ans:reduce(lambda x,y:x+y,map(lambda x:x-10,filter(lambda x:x%23==0,xrange(1000))))
“Only sheep need a shepherdâ€
 

Nanigadulocal
Side Hero
Username: Nanigadulocal

Post Number: 8053
Registered: 09-2016
Posted From: 63.79.91.18

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:28 pm:       


Gatti_gunde:

enti ee questions ila unnai ....




naa mansuloo maataa .. nuvvu cheppesav bahyatki
 

Gatti_gunde
Megastar
Username: Gatti_gunde

Post Number: 23810
Registered: 02-2010
Posted From: 71.127.150.119

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:24 pm:       

enti ee questions ila unnai .... asalu position enti inthaki
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 884
Registered: 09-2015
Posted From: 2.30.113.48

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, May 08, 2018 - 05:16 pm:       

7.
which is better approach in declaring a singleton in python..

Method -->1
=======================================
def singleton(class_):
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
instances[class_] = class_(*args, **kwargs)
return instances[class_]
return getinstance

@singleton
class MyClass(BaseClass):
pass

or

method --2
===============================================

class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]

#Python2
class MyClass(BaseClass):
__metaclass__ = Singleton

or method -->3

============================================================ =

class Singleton(object):
_instance = None
def __new__(class_, *args, **kwargs):
if not isinstance(class_._instance, class_):
class_._instance = object.__new__(class_, *args, **kwargs)
return class_._instance

class MyClass(Singleton, BaseClass):
pass
“Only sheep need a shepherdâ€
 

Sannayi_nokkulu
Megastar
Username: Sannayi_nokkulu

Post Number: 25618
Registered: 06-2014
Posted From: 68.100.232.143

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, May 07, 2018 - 06:28 am:       

https://goo.gl/images/vSqwim
Shake babu shake heritage milk shake
sachipotava , avineethi ga batukutava okkate option ante alochinchakunda chachipotaa ane type cbn - OT
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 876
Registered: 09-2015
Posted From: 2.30.113.29

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, May 07, 2018 - 03:51 am:       


Biggboss:



Intention here is not to remember return type...
In the below case it returns nothing, why?
Because set and list are mutable collections and any add/del operation on mutable has an inplace replacement... So that was intention...

Btw it should be set.add
“Only sheep need a shepherdâ€
 

Stalker
Side Hero
Username: Stalker

Post Number: 6121
Registered: 08-2012
Posted From: 71.233.224.225

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:59 pm:       


Biggboss:


ayanni pillibithiri kosens...kaani edho juniors ki annadu kada...
mana edavalu interview sethe kontamandi ilaatiyi adugutaaru :D
nenu general ga em libraries vaaderu anedi aduguta..edaina program ichi requests library use chesi raayamanta....maree ila return types meeda junk kochens ante walkout best :D
Stalker - 'S'traight talker
 

Biggboss
Side Hero
Username: Biggboss

Post Number: 3693
Registered: 08-2017
Posted From: 73.241.241.99

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:58 pm:       


Jaguar:

c# vachhinodiki entha easy/tough python ?




if you know any language and if you are willing to spend 2 weeks (chaala ekkuva) you could become an expert too

Intially konchem pythonic way lo coding kashtam ga untundhi

c#, Java annitlo decorators, generators, iterators ilanttivi untayi...so antha kashtam undadhu
 

Jaguar
Comedian
Username: Jaguar

Post Number: 1698
Registered: 01-2017
Posted From: 12.180.115.102

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:56 pm:       

c# vachhinodiki entha easy/tough python ?
 

Biggboss
Side Hero
Username: Biggboss

Post Number: 3691
Registered: 08-2017
Posted From: 73.241.241.99

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:55 pm:       


Stalker:

ideti adyakshaa set lo append ane method ye ledu..add na update set na?




inka ilanti silly questions enti...


a.append(5) antey ippudu append() method emi return chestundho gurthu unchukovali aa? I don't know understand why some of the folks are obsessed with function signature and return types

nuvvu entha pythob expert aina if you don't remember what appebnd() method returns you are disqualified annatu untayi konni kochens
 

Stalker
Side Hero
Username: Stalker

Post Number: 6120
Registered: 08-2012
Posted From: 71.233.224.225

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:47 pm:       


Viswamitra:

a = set(1,2,3)
b = a.append(5)
print b //what b prints




ideti adyakshaa set lo append ane method ye ledu..add na update set na?
Stalker - 'S'traight talker
 

Sannayi_nokkulu
Megastar
Username: Sannayi_nokkulu

Post Number: 25617
Registered: 06-2014
Posted From: 68.100.232.143

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 10:42 pm:       


Emc2:

Also they will ask size


lol u mean python size?
sachipotava , avineethi ga batukutava okkate option ante alochinchakunda chachipotaa ane type cbn - OT
 

Chesapeake
Junior Artist
Username: Chesapeake

Post Number: 714
Registered: 11-2017
Posted From: 98.183.178.62

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 08:11 pm:       

super waiting for python coding quechens
 

Emc2
Legend
Username: Emc2

Post Number: 68729
Registered: 03-2008
Posted From: 71.127.33.124

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 08:09 pm:       

Also they will ask size
 

Gotcha
Megastar
Username: Gotcha

Post Number: 29663
Registered: 02-2008
Posted From: 73.45.2.79

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 07:58 pm:       

Keep them coming
...
 

Dma
Megastar
Username: Dma

Post Number: 20370
Registered: 11-2009
Posted From: 70.184.85.54

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 07:28 pm:       

please do. thx.
Jai Andhra!! Jai Jai Andhra!!!
 

Viswamitra
Junior Artist
Username: Viswamitra

Post Number: 874
Registered: 09-2015
Posted From: 178.209.52.77

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, May 06, 2018 - 06:47 pm:       

Had some good hackathons this week, posting some good interview questions esp in python...will post the answers after some time...

mana DBers upayogam kosam...

1) what is GIL in python ? how to overcome it ?

2) what is different between range and xrange?

3) what is a generator how it is used ??

4) a = set(1,2,3)
b = a.append(5)
print b //what b prints
5) I want to construct a dict with set as a key , how can i do ??

6) which is better to use for a 1 milllion items dict.items() or dict.iteritems() ?

If you have enjoyed these question, i can post some more on pyspark and scikitlearn as well...hope this help our members esp juniors who are preparing for interviews...
“Only sheep need a shepherdâ€

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image HASH(0x9d074a8){Movie Clipart}
Show / hide regular icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Show / Hide Filmy icons selection options

Click on following links to open cliparts by Alphabetical Order

  A   B   C   D   E   F   G   H   I   J   K   L   M  

N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Password:
E-mail:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: