A quick, friendly guide to Python symbols

Python uses a lot of symbols. Some look tiny, but they do big jobs. Learn a few and your code will read better. This guide keeps things simple. Short sentences. No fluff.

Why symbols matter

Symbols tell Python what to do. They mark the start of a block, show math, or link a name to a value. Miss one and the program can crash. So this means paying attention to them will save time and bugs.

How to think about them

Treat symbols like traffic signs. They guide the flow. Follow them, and code runs smoothly. Ignore them, and things get messy fast.

Common symbols and what they do

= and ==

= assigns a value to a variable. For example, x = 5 gives x the value five. == checks if two values are the same. So you use it in conditions like if x == 5.

+, -, *, /, //, %

These do math. + and – add and subtract. * multiplies. / divides and gives a float. // divides but drops the remainder. % gives the remainder. They are the usual math tools.

:, indentation, and blocks

A colon ends a line that starts a block. For example, after if or def. Then you indent the next lines. Indentation groups those lines into a block. Get the spacing wrong and Python complains.

() , [] , {}

Parentheses ( ) group expressions and call functions. Brackets [ ] make lists or pick items by index. Braces { } create sets or dictionaries. Use the right pair for each job.

@ (decorators)

The @ symbol marks decorators. They wrap functions or classes. Think of them like a quick add-on that changes behavior without editing the original function.

* and **

* unpacks lists or collects extra positional arguments. ** does the same for keyword arguments. They are handy in functions and when you want flexible input.

# (comments)

# starts a comment. Python ignores what follows on that line. Use it to explain why something exists. Good comments help teammates — and future you.

-> (type hints)

Arrow notation shows return types in function signatures. It’s optional. Use it to make code clearer when you want others to know what a function returns.

Tips and common gotchas

Use clear names

Name variables so they make sense. x is okay for tiny examples. But real code benefits from names that explain purpose. It helps later when you read it again.

Watch equality vs identity

== checks equality. is checks identity — whether two names point to the same object. They can act the same sometimes, but not always. Use the right one for what you mean.

Beware of mutable defaults

Don’t use mutable objects like lists as default function arguments. That can cause unexpected sharing between calls. Use None and create the object inside the function instead.

Keep punctuation tight

Missing a comma, colon, or parenthesis often breaks code. Read errors from top to bottom. They usually point right to the symbol that caused the problem.

Quick reference

Here are the essentials at a glance:

– = : assignment

– == : equality check

– + – * / // % : arithmetic

– : and indentation : start blocks

– ( ) [ ] { } : grouping and collections

– * , ** : unpacking and varargs

– @ : decorators

– # : comments

Final note

Symbols are small, but they shape your code. Learn them, and you’ll write cleaner, safer programs. Start with a few, then add more as you go. It’s that simple.

Scroll to Top