Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.49 KB

File metadata and controls

44 lines (34 loc) · 1.49 KB
title Python float() built-in function - Python Cheatsheet
description Return a floating point number constructed from a number or string x.
Python float() built-in function From the Python 3 documentation Return a floating point number constructed from a number or string x.

Introduction

The float() function in Python is a built-in function that allows you to convert a number or a string containing a number into a floating-point number. This is particularly useful when you need to perform arithmetic operations that require decimal precision.

The float() function returns a floating point number from a number or a string.

Examples

float('10')
float(10)
10.0
10.0

Relevant links

  • int()
  • complex()
  • Python Data Types
  • str()
  • round()
  • String Formatting