Casting Interview Questions

    Question 1Python Integer Casting

    What will be the output of the following code?

    x = int(7.8) print(x)

    Question 2Python Float Casting

    What will be the output of the following code?

    x = float(3) print(x)

    Question 3Python String to Integer Conversion

    What will be the output?

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

    Question 4Python Invalid Casting

    What happens when we execute the following?

    x = int("Python")

    Question 5Python Boolean to Integer

    What will be the output of this code?

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

    Question 6Python Integer to Boolean

    What will be the output?

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

    Question 7Python List to String

    What will be the output of this code?

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

    Question 8Python Float String Conversion

    What is the output of this code?

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

    Question 9Python Complex Number Casting

    What will be the result of the following?

    x = complex(5) print(x)

    Question 10Python Automatic Type Conversion

    What will be the output of this expression?

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