Skip to content
Learn Netverks

Lesson

Step 7/36 19% through track

variables-types

Variables and types

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Variables and types: the syntax, APIs, and habits you need before advancing in Django.

Teams ship Variables and types on every Django codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Variables and types in contexts like: SaaS dashboards, CMS-style products, internal tools, and APIs paired with React or mobile clients.

Write Python 3 in the editor and click Run on server—the dev runner executes your script; Django framework lessons also use local startproject for full MVT (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

Python variables bind names to objects—no int x = 5 declarations. Django settings, model fields, and view context all use Python's dynamic typing with optional type hints in modern codebases.

Common types in Django code

  • str — titles, slugs, CharField values
  • int — primary keys, counts, IntegerField
  • bool — flags, BooleanField, permission checks
  • list, dict — querysets converted to lists, template context
  • None — missing optional fields, empty querysets

Truthy and falsy

Empty strings, empty lists, 0, and None are falsy—useful in templates and if queryset: checks. A queryset with rows is truthy even before you iterate.

Important interview questions and answers

  1. Q: Mutable vs immutable in Django?
    A: Strings and tuples are immutable; lists and dicts are mutable—avoid mutating shared default arguments in model methods.
  2. Q: What type is a model instance?
    A: An instance of your model class (subclass of models.Model), not a plain dict.
  3. Q: Type hints in Django?
    A: Optional but growing—helps IDEs and mypy in larger codebases.

Self-check

  1. Which values are falsy in Python?
  2. What type does Article.objects.count() return?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • None vs null?
  • f-string when?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump