DataTypes in Python_part1

In this article, I will explain about Numbers, String, and List

Data types
                Every value in Python has a datatype. Everything in Python programming is an object.

In Python Scripting/programming Language datatypes are classified into 6 types.
      • Numbers
      • String
      • List
      • Tuple
      • Set
      • Dictionary
Numbers

                      Number data types store numerical values. Numerical objects are mutable means we can change its value after assigning.



Python supports three different numerical types
      • int
      • complex
      • float
Integer(int)
                          Integer or INT in Python, is a whole number, positive or negative, without decimals.
for example


Float
                         Float or floating point number is a number it may be positive or negative which contains one or more decimals. Floating-point numbers are based on scientific notation, where numbers are written as a mantissa and an exponent.


Complex
                         
                         A complex number is created from two real numbers. Python complex number can be created using complex(a,b) function as well as using direct assignment statement. Python provides useful tools to handle and manipulate them.
                         A complex number is represented by  ' a + bi  '.
                        'i' denotes the imaginary part.      



String
                             We can’t perform mathematical operations on strings, even if the strings have numerical values. The addition (+) operator performs string concatenation, which means it combines two other strings.

String Concatenation example
List

                                          A list is a datatype which holds comma-separated values between square brackets[ ] where items need not to be the same datatype. It allows duplicate elements and it is mutable means we can change values after assigning.
An example for list assigned with different datatypes









                                                                                                                                      to be continued...


Thank you for taking the time to read my article






No comments:

Post a Comment