Django

Python Basics

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

25 pertanyaan wawancara·
Junior
1

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

Jawaban

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?

Jawaban

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?

Jawaban

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 pertanyaan wawancara

Kuasai Django untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis