Python Basic Tutorials

Python is a high level general purpose programming language which has a clear/easy learning curve. Python programming language is massively used in various domains like Artificial Intelligence, Data Science, Web Development, Utilities Tools and Scripts and many more

Python is a Programming language, and the default Python we use is written in C programming language which is also referred to as CPython (Python implementation in C). There are various implementation of Python Programming language i.e Jython(in JAVA), Skulpt(in JS) e.t.c

To make everything easy: We refer CPython as Python

Number Datatype in Python

Numeric data types in python stores numbers. These numbers may be of integer, float or complex data types. Integers are simply the numeric value which is not separated by decimal values. But the float values are also the numeric values but are not separated by decimal values. For example, 5 is an integer, and 5.0 is float.

Complex numbers are written in the form,x + yj where x is the real part and y is the imaginary part. We can use type() function to find out the class of the particular assigned variable.


a=12
b=12.0
c=3+6j
print(type(a))
print(type(b))
print(type(c))
Output:
<class 'int'>
<class 'float'>
<class 'complex'>
Python number type conversion

In python, we can convert one kind of datatypes into another which is called type conversion. Integer and float can be operated within all the operators implicitly(automatically)


>>>2+3.2
   5.2
>>>2*3.5
   7.0

We can also convert one kind of datatypes into another explicitly using int(), float(), or complex() functions.

Example:

>>>int(2.3)
   2
>>>int(7.9)
   7
>>>float(6)
   6.0
>>>complex(7)
   (7+0j)