Casting Interview Questions

    Question 1: Python Integer Casting

    What will be the output of the following code?

    x = int(7.8) print(x)

    Question 2: Python Float Casting

    What will be the output of the following code?

    x = float(3) print(x)

    Question 3: Python String to Integer Conversion

    What will be the output?

    x = int("25") print(x + 5)

    Question 4: Python Invalid Casting

    What happens when we execute the following?

    x = int("Python")

    Question 5: Python Boolean to Integer

    What will be the output of this code?

    print(int(True), int(False))

    Question 6: Python Integer to Boolean

    What will be the output?

    print(bool(0), bool(5))

    Question 7: Python List to String

    What will be the output of this code?

    x = str([1, 2, 3]) print(x)

    Question 8: Python Float String Conversion

    What is the output of this code?

    x = float("12.34") print(x + 1)

    Question 9: Python Complex Number Casting

    What will be the result of the following?

    x = complex(5) print(x)

    Question 10: Python Automatic Type Conversion

    What will be the output of this expression?

    x = 10 + 3.5 print(type(x))