Python Type Casting Presentation


This is the presentation associated with the python type casting video.

Download Presentation

Python Type Casting Video Question

This is the question that was asked in the python Type Casting video

Question : What is the output of following code?
In [ ]:
num1 = "25.5"
num2 = "5"

print("Sum =", int(num1)+int(num2))
In [1]:
num1 = "25.5"
num2 = "5"

print("Sum =", int(num1)+int(num2))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-c312dc81eb3c> in <module>
      2 num2 = "5"
      3 
----> 4 print("Sum =", int(num1)+int(num2))

ValueError: invalid literal for int() with base 10: '25.5'