# string to intint("42")#ans: 42int("100")#ans: 100#ans: float to int (truncates)int(3.14)#ans: 3int(9.99)#ans: 9
# string to floatfloat("3.14")#ans: 3.14#ans: int to floatfloat(42)#ans: 42.0float(0)#ans: 0.0
# int to stringstr(42)#ans: "42"#ans: float to stringstr(3.14)#ans: "3.14"#ans: bool to stringstr(True)#ans: "True"
# number to boolbool(1)#ans: Truebool(0)#ans: Falsebool(-5)#ans: True#ans: string to boolbool("")#ans: Falsebool("text")#ans: True
# list to boolbool([])#ans: Falsebool([1, 2])#ans: True#ans: None to boolbool(None)#ans: False
# what is the result?int("100")#ans: 100# what happens?int("3.14")#ans: ValueError
# float from string?float("3.14")#ans: 3.14# bool from number?bool(0)#ans: Falsebool(1)#ans: Truebool(-1)#ans: True
# bool from string?bool("")#ans: Falsebool("False")#ans: True (any non-empty string is True)
# string from bool?str(True)#ans: "True"# int from bool?int(False)#ans: 0int(True)#ans: 1
# what about this?int(" 42 ")#ans: 42 (whitespace is stripped)# edge case?int("0b101", 2)#ans: 5 (binary to int)
# what happens?float("inf")#ans: inf (infinity)# string to int base?int("FF", 16)#ans: 255 (hex to int)
# float to int?int(3.9)#ans: 3 (truncates, doesn't round)# bool from empty?bool({})#ans: False
Google tag (gtag.js)