Django

Python Basics

Variables & constants, data types, control flow, functions, list comprehensions, decorators, context managers

25 câu hỏi phỏng vấn·
Junior
1

What is the difference between a variable declared with = and a constant in Python?

Câu trả lời

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.

2

What data type does the expression 3 / 2 return in Python 3?

Câu trả lời

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.

3

What is the difference between a list and a tuple in Python?

Câu trả lời

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.

4

How to check if a key exists in a Python dictionary?

5

What is the difference between == and is in Python?

+22 câu hỏi phỏng vấn

Nắm vững Django cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí