Friday, May 29, 2020

Type Casting


Python offers two simple functions to specify a type of data and solve this problem - here they are: int () and float ().

Their names are self-commenting.

The int () function takes one argument & tries to convert it into an integer; if it fails, the whole program will fail too.
The float () function takes one argument & tries to convert it into a float; if it fails, the whole program will fail too.

Let’s run the following code.






Output is,






We will consider next code. This is known as “right-angle triangle” program.


Output is,



No comments:

Post a Comment