---
title: Types, Values, and Errors in Python
source: https://app.sythra.ai/learn/python/types-values-errors
topic: Python
updated: 2026-08-12
publisher: Sythra (https://app.sythra.ai)
---

# Types, Values, and Errors in Python

Every piece of data in Python has a value and a type. Use type() to see int, float, or str — and learn why some bugs crash loudly while semantic errors run quietly with the wrong answer.

_Source: [https://app.sythra.ai/learn/python/types-values-errors](https://app.sythra.ai/learn/python/types-values-errors) — free to read on Sythra._

## Key points

- A value is a concrete piece of data; a type is what kind of thing it is
- type() reports int, float, str, and more
- Quotes make "17" a string, not an integer
- 1,000,000 is three integers (a tuple), not one million — use 1_000_000
- Syntax errors break language rules; runtime errors fail during execution; semantic errors are wrong meaning with no crash
- Silent wrong answers are often the hardest bugs to catch

Want to understand **types, values, and errors in Python**? Every piece of data you write has both a _value_ (what it is) and a _type_ (what kind of thing it is). Miss either one, and you get bugs — some loud, some silent.

This page is the mental model before variables and operators: what Python sees when you type a number or a word, how to ask with `type()`, and how syntax, runtime, and semantic errors differ when things go wrong.

## What you will learn

By the end you can:

- Explain what a **value** is vs what a **type** is
- Use `type()` to inspect `int`, `float`, and `str`
- Spot when quotes turn a “number” into text
- Avoid the `1,000,000` comma trap (a classic semantic error)
- Tell **syntax**, **runtime**, and **semantic** errors apart
- Treat silent wrong answers as the most dangerous class of bug

> We are **not** covering variables, assignment, or full data-structure types yet. This page is how Python classifies the small pieces you type — and how it fails when the classification or the meaning is wrong.

## Values and types — every piece of data has an identity

When you first talk to Python, you start with simple things — numbers and words:

```python
1
2
"hello"
```

Python understands each of these. Quietly, though, it is doing something important: it is **classifying** everything you say.

A **value** is one of the most basic things in a program — a concrete piece of data. `2` is a value. `"Hello, World!"` is a value.

Python does not only care _what_ the value is. It also cares **what kind** of thing it is:

- `2` arrives as a **number**
- `"Hello, World!"` arrives as **text**

Those identities are called **types**. The type decides which operations make sense later — you can add two numbers; you cannot divide a word by another word and expect a normal result.

## Ask Python with type()

If you are unsure what Python thinks a value is, ask it:

```python
type("hello, world")
# <class 'str'>

type(17)
# <class 'int'>
```

A pattern forms quickly:

- Text inside quotes → `str` (string)
- Whole numbers → `int` (integer)

Then you type a number with a decimal point:

```python
type(17.5)
# <class 'float'>
```

Why **float**? Decimal numbers are stored with **floating-point representation** — they are not fixed whole units like integers; the decimal point can “float” in how the number is represented.

## Quotes change the type

Appearances lie. Try this:

```python
type("17")
# <class 'str'>
```

It _looks_ like a number. Quotation marks still win. Inside quotes, Python treats it as **text**, not a number. That single detail causes countless beginner bugs when you later try to do math on user input that arrived as a string.

## A quiet mistake: writing 1,000,000

You want one million. You instinctively write commas the way you would on paper:

```python
1,000,000
```

Python does not complain. No red text. No crash. It calmly gives you something like:

```python
(1, 0, 0)
```

It did not see **one million**. It saw **three separate integers**, separated by commas (a tuple). You meant one value; you wrote three.

This is a classic **semantic error**: the program is legal, it runs, and the meaning is still wrong. Write one million as `1000000` or `1_000_000` (underscores are allowed as digit separators in modern Python).

## Three kinds of errors

Sometimes Python refuses to listen. Sometimes it listens, then crashes halfway. Sometimes — the worst case — it listens, runs, and quietly betrays your intention.

Those failures are all “errors,” but they are not the same kind of failure. (For how interpreters surface errors while running, see [Programs, Interpreters & Compilers](/learn/python/programs-interpreters-compilers).)

### Syntax errors — the language rules are broken

A **syntax error** means Python cannot even parse what you wrote. The structure of the language is broken — missing quotes, unbalanced parentheses, illegal indentation.

```python
print("hello
# SyntaxError: unterminated string literal
```

Think of it like broken grammar in English: the listener cannot decide what the sentence was supposed to be. **Python never starts running the rest of the program** until the syntax is fixed.

### Runtime errors — legal code that fails while running

A **runtime error** (often called an **exception**) means the grammar was fine, but something went wrong during execution.

```python
print(10 / 0)
# ZeroDivisionError: division by zero
```

Python understood the instruction. It started running. Then it hit an impossible situation.

```python
x = 10
print(y)
# NameError: name 'y' is not defined
```

You asked for a name that does not exist yet. Runtime errors are accidents **during execution** — not before.

### Semantic errors — runs fine, meaning is wrong

A **semantic error** (a logic bug) is the most dangerous class for beginners. The program is legal. It finishes. There is no traceback. The _idea_ was wrong.

The `1,000,000` example is one. Here is another:

```python
minutes = 60
hours = minutes / 24
print(hours)
# 2.5  — runs, but the formula is wrong (should be / 60)
```

Perfect “grammar.” Wrong meaning. Python did exactly what you wrote — not what you intended.

## Error types at a glance

| Kind | When it shows up | What to fix |
| --- | --- | --- |
| Syntax | Before the program really runs | Language rules — quotes, parentheses, indentation |
| Runtime | While the program is executing | The situation — missing name, divide by zero, bad input |
| Semantic | Often never as an error message | Your logic — the program’s meaning |

Rule of thumb: if Python refuses to read your sentence, fix the grammar. If it crashes mid-run, fix the situation. If it smiles and gives the wrong answer — **fix your thinking**.

## Putting it together in a few lines

A short interactive-style session that checks types and avoids the comma trap:

```python
print(type(17))        # <class 'int'>
print(type(17.5))      # <class 'float'>
print(type("17"))      # <class 'str'>  — quotes win

million = 1_000_000    # one million (not a tuple)
print(million)
print(type(million))   # <class 'int'>
```

> **Practice on Sythra:** Reading the model is step one. Agentic mode can quiz you on int vs float vs str, type(), and how the three error kinds differ — until you can teach it back. [Open AI tutor →](https://app.sythra.ai/pricing)

## Common mistakes

- Assuming `"17"` is a number — quotes make it a `str`
- Writing `1,000,000` for one million — that is three values, not one
- Ignoring `type()` when debugging surprising behavior
- Treating every crash the same — syntax vs runtime need different fixes
- Trusting a program that “runs with no errors” — semantic bugs leave no traceback
- Memorizing type names without typing a few examples in interactive mode

## FAQ

### What is a value in Python?

A value is a concrete piece of data your program works with — for example 17, 3.14, or "hello". Every value also has a type that says what kind of thing it is.

### What is a type in Python?

A type is the category Python assigns to a value, such as int for whole numbers, float for decimals, and str for text. The type decides which operations make sense.

### What does type() do in Python?

type() tells you the type of a value. For example type(17) is int, type(17.5) is float, and type("17") is str because of the quotes.

### Why is type("17") a string and not an int?

Quotation marks mark text. Even if the characters look like digits, Python treats anything inside quotes as a str until you convert it.

### Why does 1,000,000 not mean one million in Python?

Commas separate values. 1,000,000 is three integers (a tuple), not the number one million. Write 1000000 or 1_000_000 instead.

### What is the difference between syntax, runtime, and semantic errors?

Syntax errors break language rules and stop the program before it runs. Runtime errors (exceptions) happen while the program is running. Semantic errors produce wrong results even though the program runs without crashing.

## Related

- [Programs, Interpreters & Compilers in Python](https://app.sythra.ai/learn/python/programs-interpreters-compilers) — How programs run, and why interpreters surface errors the way they do.
- [Logical Operators in Python](https://app.sythra.ai/learn/python/logical-operators) — and, or, not — combine True/False values once types click.
- [Variables in Python](https://app.sythra.ai/learn/python/variables) — Name and store typed values — assignment, updates, naming.
- [Comments in Python](https://app.sythra.ai/learn/python/comments) — # notes for humans — useful comments vs noise, and docstrings.
- [Operators and Operands in Python](https://app.sythra.ai/learn/python/operators-operands) — Arithmetic, comparison, assignment, in, is — the operator map.
- [Statements vs Expressions in Python](https://app.sythra.ai/learn/python/statements-vs-expressions) — REPL vs script — expressions produce values, statements act.
- [Order of Operations in Python](https://app.sythra.ai/learn/python/order-of-operations) — PEMDAS, precedence, parentheses, and left-to-right ties.
- [Data Types in Python](https://app.sythra.ai/learn/python/data-types) — int, float, str, bool, list, tuple, dict, set — the full map.
- [The input() Function in Python](https://app.sythra.ai/learn/python/python-input-function) — Reading user input and converting it from a string to a number.
- [Strings in Python](https://app.sythra.ai/learn/python/strings-in-python) — Indexing, slicing, immutability, and string methods.
- [Dictionaries in Python](https://app.sythra.ai/learn/python/dictionaries-in-python) — Key-value pairs, the histogram pattern, and memoization.
- [Type Casting in Python](https://app.sythra.ai/learn/python/type-casting) — Implicit vs explicit conversion between data types.
- [Comparison Operators in Python](https://app.sythra.ai/learn/python) — ==, !=, <, > — compare values before branching.
- [Python course hub](https://app.sythra.ai/learn/python) — All free Python explainers and the path into Agentic practice.

---

Written by Sythra — Learn machine learning by building. Practice this topic with Sythra's AI tutor: https://app.sythra.ai/pricing
