Round2 Interview Question
In the interview , for a company (energy investments / commodities) a panel of 3 interviewers asked me the following during a discussion .
Panel: Let's talk about some important Python details. It's ok if you don't remember things. Just an approximate answer will be fine for us.
So, in Python, what is the difference between a List comprehension and a Generator expression. In a few words...
Correct answer: A generator expression is like a list comprehension, except that it doesn't store the list in memory.
Panel: Give some example . Write here in the tablet.
Answer:
list comprehension:
simulated_returns = [price * volatility for price in historical_data]
portfolio_value = sum(simulated_returns)
generator:
simulated_returns = (price * volatility for price in historical_data)
portfolio_value = sum(simulated_returns)
15
8 comments
Babette Pascal
3
Round2 Interview Question
powered by
Energy Data Scientist 2026
skool.com/software-school-for-energy-7177
A beginner-friendly program for a career in technical roles in the energy sector. Regardless of your location, age, sex, education or experience.
Build your own community
Bring people together around your passion and get paid.
Powered by