Python Engineer Interview Questions

6,411 python engineer interview questions shared by candidates

Thanks for applying to our position. To further analyze your skills in Python, I would like for you to analyze the below code and answer the questions, def advert_match_geo(advert, country_id): if advert.countries: if advert.geo_setting == 'Include': matching_countries = tuple(filter(lambda x: not x or x == country_id, advert.countries)) if advert.geo_setting == 'Include' and not matching_countries: return False elif advert.geo_setting == 'Exclude': matching_countries = tuple(filter(lambda x: x == country_id, advert.countries)) if advert.geo_setting == 'Exclude' and matching_countries: return False return True Q: What does this code do? Q: Is this code syntactically valid? Q: What is wrong with the algorithmic structure of this code? Q: Assume that this function is called frequently with similar inputs. Is this function a good candidate for caching / memorization?

Python Developer

Interviewed at WWWPromoter

2.2
Feb 27, 2017

Thanks for applying to our position. To further analyze your skills in Python, I would like for you to analyze the below code and answer the questions, def advert_match_geo(advert, country_id): if advert.countries: if advert.geo_setting == 'Include': matching_countries = tuple(filter(lambda x: not x or x == country_id, advert.countries)) if advert.geo_setting == 'Include' and not matching_countries: return False elif advert.geo_setting == 'Exclude': matching_countries = tuple(filter(lambda x: x == country_id, advert.countries)) if advert.geo_setting == 'Exclude' and matching_countries: return False return True Q: What does this code do? Q: Is this code syntactically valid? Q: What is wrong with the algorithmic structure of this code? Q: Assume that this function is called frequently with similar inputs. Is this function a good candidate for caching / memorization?

Viewing 3221 - 3230 interview questions

Glassdoor has 6,411 interview questions and reports from Python engineer interviews. Prepare for your interview. Get hired. Love your job.