Posts

Showing posts with the label Type conversion

4.Basic Python Data Types-Numbers and Strings,Type conversions

Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. There are various data types in Python. Some of the basic types are listed below. Python Numbers Integers, floating point numbers and complex numbers fall under Python numbers category. They are defined as int, float and complex classes in Python. We can use the type() function to know which class a variable or a value belongs to. Similarly, the isinstance() function is used to check if an object belongs to a particular class. Integers can be of any length, it is only limited by the memory available. A floating-point number is accurate up to 15 decimal places. Integer and floating points are separated by decimal points. 1 is an integer, 1.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. Here are some examples. >>>a=5 &