Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 121 - 2612_Digimind
P. 121

    Integer/Long: Integers are whole numbers consisting of + or – signs. They do not have decimal
                       places between them. For example, 87, -3 are called integer numbers.

                       Float: Float data type represents numbers that contain a decimal point. For example, 0.6, -3.257
                       are called floating-point numbers. These numbers can also be written using ‘e’ or ‘E’ to represent
                       the power 10.

                       Complex: Complex numbers consist of a real part and an imaginary part. It is represented as
                       a + bj, where j is the imaginary unit.

                     SEQUENCE
                     A sequence is an ordered collection of items of similar or different data types. The three types of
                     sequence data types are Strings, Lists and Tuples.

                       Strings: A string is a sequence of one or more characters put in single quotes, double quotes
                       or triple quotes which is used to represent text-based information. The quotes are not a part of
                       the string. For example, "hello","Orange Education", 'Amit', '365'.

                       List: A list is a collection of data elements separated by comma (,) and enclosed within square
                       brackets []. We can also create a list with the elements that are the same or have different
                       data types. For example, [1,2,5], ['HELLO',45,87.6].

                       Tuple: A tuple is just like a list. It contains a group of elements that can be of different data
                       types. The elements in the tuple are separated by commas (,) and enclosed in parentheses
                       (). The difference between a list and a tuple is that list can be modified but tuples cannot be
                       modified after it is created. For example, (7, 9.5, 3), ('a',4,3).

                     MAPPING

                     The mapping data type in Python is used to store data in the form of key–value pairs. Python
                     provides one built-in mapping data type called is as follows:

                       Dictionary (dict): A dictionary stores values mapped to unique keys. Each key is associated
                       with a value.

                     BOOLEAN
                     Boolean is a data type with two built-in values: True or False. They are used in logical evaluation.
                     A True statement returns value 1 while a False statement returns value 0.

                     SETS
                     A set in Python is a built-in data type used to store a collection of unique elements. It is unordered,
                     mutable and does not allow duplicate values.

                     TYPE CONVERSION IN PYTHON

                     Type conversion in Python refers to changing the data type of a variable from one type to another.
                     It can be classified into two types:

                                                                                        Tokens and Data Types in Python  119

| 116 117 118 119 120 121 122 123 124 125 126 |