Python / Core Python Fundamentals Interview Questions
How do variables work in Python, and what does dynamic typing mean?
In Python a variable is simply a name that points to an object in memory. You do not declare the type — you just assign a value and Python figures out the type at runtime. That is what dynamic typing means: the type is attached to the object, not to the name.
x = 10 # x points to an int object
x = 'hello' # now x points to a str object — perfectly legal
x = [1, 2, 3] # now x points to a list
print(type(x)) # Each assignment rebinds the name to a new object; the old object is garbage-collected when nothing else references it. This is why Python variables behave more like labels than typed containers.
Dynamic typing provides flexibility but can hide bugs that a static-type compiler would catch at build time. Python 3.5+ addresses this with optional type hints (PEP 484) that tools like mypy can check without changing runtime behaviour.
Naming conventions: use lowercase with underscores (snake_case) for variables and functions, ALL_CAPS for module-level constants. Python is case-sensitive, so count and Count are two different names.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
