---
title: "float"
space: "Student Handbook"
url: "https://portal.cs17.org/student-handbook/python-manual/built-in-functions/float"
updated: "2026-10-05"
---

Converts a value to a number with a decimal point.

## Synopsis

```python
float(value)
```

## Description

Use `float` when the user may type a decimal, such as a price or a height.

Floats are stored in a fixed number of bits, so most decimals are only close, not exact. That is why `0.1 + 0.2` is not exactly `0.3`.

## Parameters

| Name | Meaning |
| --- | --- |
| `value` | A string such as `"3.5"`, or a whole number. |

## Return value

A `float`.

## Example

```python
price = float(input("Price: "))
print(price * 2)
print(float(7))
print(0.1 + 0.2)
```

It prints:

```text
Price: 3.5
7.0
7.0
0.30000000000000004
```

## Common mistake

```python
n = float(input("Number: "))
```

Python stops with:

```text
Number: 3,5
ValueError: could not convert string to float: '3,5'
```

Python uses a dot for the decimal point, never a comma.

## See also

[int](/student-handbook/python-manual/built-in-functions/int), [round](/student-handbook/python-manual/built-in-functions/round), [f-strings](/student-handbook/python-manual/strings/f-strings)

[float in the Python documentation](https://docs.python.org/3/library/functions.html#float)
