Take two variables ‘x’ and ‘y’. Save an integer value (e.g. 5) in x and floating value (e.g. (5.7) in y. Change the type of integer value to float and floating value to int. Now print both numbers and observe the result.

Here is the code:

#Take two variables ‘x’ and ‘y’. Save an integer value (e.g. 5) in x and floating value (e.g. (5.7) in y. #Change the type of integer value to float and floating value to int. Now print both numbers and observe the result.
x = 5
y = 5.7
print('X = ', x, '(Integer data type)')
print('Y = ', y, '(Float data type)')
print('After changing the data type of both the variables:')

a = float(x)
b = int(y)
print('X = ', a, '(Float data type)' )
print('Y = ', b, '(Integer data type)')

# This code is contributed by Ahmad Shafiq

callout-flag

Love this read? Subscribe to Modernage!

Do you have any queries? You can ask in the comments. We, at Modernage answer each and every question, asked in the comments, so If you have any queries, or you want to know about any specific platform you can ask in the comments below

Author

This Post Has 2 Comments

  1. gold ira companies

    Hi, I do believe this is a great site. I stumbledupon it
    😉 I may return once again since i have book marked it.
    Money and freedom is the greatest way to change, may you be rich and continue to guide others.

Leave a Reply

girl-carrying-document

More Articles.

girl-carrying-document

More Articles.