Python: Convert Int, Float, String

By Xah Lee. Date: .

Python doesn't automatically convert between {int, float, string}.

Convert float to int

int(3.2)

Convert int to float

float(3)

You can write with a dot after the number as float, like this: 3.

Convert Number to String

use โ€œformatโ€ method. [see Format String]

Python

Overview

Help

Comment

String

Arithmetic

Boolean

Conditional

Loop, Iteration

Data Structure

Function and Class

Module

Misc

Regex

Text Processing

Web

Misc