Skip to content
Learn Netverks

Lesson

Step 7/36 19% through track

variables-types-python

Variables and types

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

This lesson

This lesson teaches Variables and types: the syntax, patterns, and safety habits you need before advancing in Python.

Teams still ship Variables and types in Python codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Variables and types in contexts like: Scripts, Django/FastAPI apps, notebooks, and glue code between systems.

Write Python 3 in the editor and click Run on server—the dev runner executes your script with print() for output; stdlib only in playground snippets (LEARNING_RUNNER_ENABLED=true).

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

Python variables are names bound to objects—no int x = 5 type declarations like Java. Types live on objects; names can rebind to different types at runtime, similar to JavaScript but with stricter rules (e.g., no implicit string+number concat).

Common built-in types

  • int, float — numbers (arbitrary-precision ints)
  • str — Unicode text, immutable
  • boolTrue or False (capitalized)
  • None — absence of value, like null in JS

Assignment and type()

count = 10
ratio = 0.75
name = "Ada"
ok = True
print(type(count), type(name))

Use type() or isinstance() at runtime. Optional static type hints come later—compare with C# compile-time checks.

Important interview questions and answers

  1. Q: Dynamic vs static typing?
    A: Python resolves types at runtime on objects; Java/C# enforce variable types at compile time.
  2. Q: Mutable vs immutable scalars?
    A: int, float, str, tuple are immutable; list, dict, set are mutable.

Self-check

  1. What does type(3.14) return?
  2. Can a name rebind from int to str?

Pitfall: Names bind to objects—a = b for lists aliases the same list, unlike copying value types in C# structs.

Interview prep

Dynamic typing meaning?

Types attach to objects; names can rebind to different types—checked at runtime, optionally annotated for static tools.

None vs False?

None is the null sentinel; False is a boolean—both are falsy but distinct objects.

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

  • Dynamic typing?
  • None vs null?

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