HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to Python: Print and RepeatVariablesData Types & NumbersStringsListsConditions (if / elif / else)Loops (for / while)FunctionsOperatorsDictionariesTuples & SetsError Handling (try / except)Classes (Object-Oriented)File OperationsComments & IndentationBooleans (True / False)Lambda & map / filterModules (import)InheritanceVariable Scope
REFERENCE
📖 Overview
🖥️ Output & Input
🔢 Numbers & Math
✍️ String
📋 List
🗂️ Dictionary & Set
🔁 Condition & Loop
🧩 Function
📁 File & Error
🔄 Type & Conversion
int() / float()str()type() / isinstance()bool() / True-False
Python›REFERENCE›Type & Conversion›int() / float()

int() / float()

Converts text/a number to an integer or float.

Syntax

int(value) · float(value)

Description

int() converts to an integer, float() to a float. It's essential for turning input() text into a number. Text that can't be converted raises an error.

Returns

The converted number.

Example

Loading editor…

Expected output

50
7.0
9

When to use?

Taking text coming from the user/a file into a calculation.

Common mistakes

  • ⚠️ int("3.5") raises an error; use float("3.5") first, then int().
  • ⚠️ int() cuts off the decimal downward; it doesn't round.

Related commands

str()input()round()
str() →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code