0% found this document useful (0 votes)
3 views

Data Handling

The document provides an overview of Python's built-in data types, including numbers, sequences, sets, and mappings, along with their mutability and characteristics. It also explains variable internals, including object attributes and types of operators such as arithmetic, relational, and identity operators. Additionally, it highlights the differences between mutable and immutable types and the comparison methods for various data types.

Uploaded by

darkwolfx2244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Data Handling

The document provides an overview of Python's built-in data types, including numbers, sequences, sets, and mappings, along with their mutability and characteristics. It also explains variable internals, including object attributes and types of operators such as arithmetic, relational, and identity operators. Additionally, it highlights the differences between mutable and immutable types and the comparison methods for various data types.

Uploaded by

darkwolfx2244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Iterable→Any object that can return its members, one at a time.

Built-in core data types


List→Numbers, strings, lists, tuples, dictionaries
Numbers
Content→Numeric values

Sub-types
Integers
Content→Whole numbers that have no fractional part

Sub-types
Integers (signed)
Content→Integers that can be both positive and negative
Length restriction→None

Sub-types
Big
Small

Booleans
Content→Truth values True and False

Floating-point numbers
Content→Numbers having fractional parts
Forms (Notations)
Fractional form→Normal decimal notation
Exponent form→a.bEe (a.b * 10e)
OverflowError↔Error raised if a given number cannot be represented
through the available number of bytes #PythonError
Advantages over integers
They can represent values between the integers.
They can represent a much greater range of values.
Disadvantages over integers
Floating-point operations are usually slower than integer
operations.
Precision→Double precision (15 digits)
Complex numbers
Forms (Notation)→A + Bj
Serialisation→Python prints the complex number in parenthesis if it
has a nonzero real part.
Difference in memory allocation→Complex literals and complex
variables may have different IDs even if they are equal
Components
Real component (floating point)
Imaginary component (floating point)

Sequences
Strings
Content→Any number of valid Unicode characters in a set of quotation
marks
Mutability→Immutable

Lists and Tuples


Lists
Content→A comma-seperated list of values of any datatype
Mutability→Mutable
Tuples
Content→Lists that cannot be changed
Mutability→Immutable
Sets
Mutability→Mutable, but elements cannot be
Difference between sets and lists
Sets are created by specifying comma separated values within flower
brackets.
Sets' elements are unordered and unindexed.
Sets do not allow duplicate entries.
Sets cannot contain mutable elements.
Mappings
Dictionaries
Content→An unordered set of comma-separated key:value pairs enclosed
with flower brackets

Mutable types→Lists, dictionaries, sets


Immutable types→Integers, floats, booleans, strings, tuples
Changing in place→Modifying the same value in the same memory location

Variable Internals
Object↔An entity that has certain properties and that exhibits a certain type
of behaviour
Attributes→Type, value, id
Type→Determines the operations that can performed on the object
Displayed using→type()
Value→The data-item contained in the object
Displayed using→print()
ID→The memory location of the object
Displayed using→id()

Operators
Types of operators
Identity
Bitwise
Membership
Arithmetic
Relational
Logical

Arithmetic Operators
Types
Unary→Operators that act on one operand
List→Unary +, Unary -
Binary→Operators that act on two operands
List
Addition
Subtraction
Multiplication
Division
Floor division
Modulus
Exponentiation
Augmented Assignment→Combinations of arithmetic and assignment
operators
Relational Operators↔Determine the relation among different operands
List←Less than (<), greater than (>), equal to (==), less than or equal to
(<=), greater than or equal to (>=), not equal to (!=)
How numeric types are compared→Trailing zeroes are moved, then the numbers
are compared
How strings are compared→Based on lexicographical ordering (ordering in a
dictionary)
How lists and tuples are compared→They are equal if they have the same
elements in the same order, otherwise they are compared element by element
How booleans are compared→True is 1, False is 0
Why floating point values should not be compared with ==→They are stored
with a precision limit which may result in rounding off.
Identity Operators↔Check if both operands reference the same object memory
List→is, is not
Cases in which Python creates different objects for two variables with the
same value
Input strings from the console beyond single characters
Integer literals from -6 and below and 257 and above (big integers)
Floating point and complex literals

You might also like