Wednesday, 23 July 2025

Python Integer methods

 Integer methods


x = 42

float(x)              # 42.0

int(3.14)             # 3

abs(-5)               # 5

round(3.75)           # 4

pow(2, 3)             # 8

divmod(9, 4)          # (2, 1)

bin(10)               # '0b1010'

hex(255)              # '0xff'

oct(8)                # '0o10'


No comments:

Post a Comment

Python Tuple , Set and Dict

 Tuple Methods : t = (1, 2, 3) t.count(2)            # 1 t.index(3)            # 2 #Set methods : s = {1, 2, 3} s.add(4)              # {1, ...