
Python Basics
Variables & constants, data types, control flow, functions, list comprehensions, decorators, context managers
1What is the difference between a variable declared with = and a constant in Python?
What is the difference between a variable declared with = and a constant in Python?
Answer
Python does not have true constants at the language level. By convention, UPPERCASE variables are considered constants and should not be modified, but nothing technically prevents reassignment. This PEP 8 convention relies on developer discipline rather than language enforcement.
2What data type does the expression 3 / 2 return in Python 3?
What data type does the expression 3 / 2 return in Python 3?
Answer
In Python 3, the / operator always performs floating-point division, returning 1.5 in this case. To get integer division, use the // operator. This is a major difference from Python 2 where / performed integer division between two integers.
3What is the difference between a list and a tuple in Python?
What is the difference between a list and a tuple in Python?
Answer
Lists are mutable (modifiable after creation) while tuples are immutable. Tuples are slightly more performant and can be used as dictionary keys. Lists use square brackets [] and tuples use parentheses (). Choose the right type based on whether data needs to be modified.
How to check if a key exists in a Python dictionary?
What is the difference between == and is in Python?
+22 interview questions
Other Django interview topics
Python OOP
Django Fundamentals
Django Models - Basics
Django Views
Django Templates
Django Forms
Advanced QuerySets
Django Authentication
Django Middleware
Django Admin
Django REST Framework
Django Signals
File Upload
Django Caching
Django Sessions
Django Email
Django Testing
Django Security
Django Deployment
Advanced Django ORM
Django Performance
Django & Celery
Django Channels
Django & GraphQL
Django & Docker
Django in Microservices Ecosystem
Custom Django Commands
Django Internationalization
Django Design Patterns
Django Async & ASGI
Settings & Production Configuration
Observability & Monitoring
Master Django for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free