learnpython24-(Python Numbers, Type Conversion and Mathematics)
Python Numbers, Type Conversion and Mathematics In this article, you'll learn about the different numbers used in Python, how to convert from one data type to the other, and the mathematical operations supported in Python. Number Data Type in Python Python supports integers, floating-point numbers and complex numbers. They are defined as int , float , and complex classes in Python. Integers and floating points are separated by the presence or absence of a decimal point. For instance, 5 is an integer whereas 5.0 is a floating-point number. Complex numbers are written in the form, x + yj , where x is the real part and y is the imaginary part. We can use the type() function to know which class a variable or a value belongs to and isinstance() function to check if it belongs to a particular class. Let's look at an example: a = 5 print (type(a)) print (type( 5.0 )) c = 5 + 3j print (c + 3 ) print (isi...