codegurukool.com · Free coding tutorials & online compiler

Home › Python Tutorial › Python data types, numbers and casting

Python data types, numbers and casting

int, float, str and converting between them.

Whole numbers are int, decimals are float. Convert with int(), float() and str(). // is whole-number division, % the remainder and ** the power.

Example code

a = 7
b = 2.5
c = "3"
print(a + b)
print(int(c) + a)
print(type(b))
print(7 // 2, 7 % 2, 2 ** 5)

Run this code in the online editor

← Python variables and outputPython strings and string formatting →