Page 170 - Computer Science Class 11 With Functions
P. 170

Ø   type() is used to get the data type of an object.
          Ø   A Python sequence is an ordered collection of items. Each item in a sequence is indexed by an integer.
          Ø   Strings (str), lists (list), and tuples (tuple) are examples of sequence types.
          Ø   A string is a sequence of characters enclosed in single (') or double (") quotation marks.
          Ø   A string enclosed between single or double quotation marks is usually restricted to one line, but a longer
              string may be continued on next line by terminating the line with a backslash character.  For example,
              >>> 'Hello,\
              …   How are you?'

                  'Hello,How are you?'
          Ø   A list is a sequence of objects (possibly heterogeneous) enclosed in square brackets: [].
          Ø   A tuple is a sequence of  objects (possibly heterogeneous)  enclosed in parenthesis ().
          Ø   A  set  is  an  unordered  and  unindexed  collection  of  data  items  separated  by  a  comma  enclosed  in  curly

              brackets {}.
          Ø   The type NoneType has only one member, namely, None.
          Ø   A dictionary is an unordered set of key-value pairs enclosed in curly brackets {}.

          Ø   Numeric data types (int, float, and complex), bool, str, and tuple are immutable data types.
          Ø   Lists and dictionaries are mutable data types.
          Ø   Operators are used to perform an operation on the values, called operands.
          Ø   A unary operator requires only one operand, while a binary operator requires two operands.
          Ø   The  arithmetic  operators  are  used  to  perform  arithmetic  operations:  addition  (+),  subtraction(-),
              multiplication(*), division(/, %,//), and exponentiation(**).
          Ø   Assignment operators are used to assign the value of the operand on the right-hand side of the assignment
              operator to the operand on the left-hand side of the operator.

          Ø   There are three logical operators: not, and, or.
          Ø   Identity operators are used for checking the data type of a variable.
          Ø   There are two identity operators: is and is not.
          Ø   Membership operators are used to check whether a particular value is a member of a given string, list, tuple,
              set, or dictionary. A membership operation yields True or False.
          Ø   An expression in Python is defined as a valid combination of objects and operators.
          Ø   When  an  expression  contains  multiple  operators,  Python  resolves  the  order  of  execution  according  to
              precedence of operators.
          Ø   Type conversion is the process of converting the value of one data type to another.
          Ø   Implicit type conversion, also known as coercion, takes place when a data value is converted from one data
              type to another by the Python interpreter, without explicit type conversion by the programmer. For example,
              3+4.6 yields a floating point number.
          Ø   Explicit conversion, also called typecasting, takes place when a programmer gives such an instruction. For
              example, int(7.4).
          Ø   If the rules of a programming language are not followed, the interpreter/compiler will flash an error. Such
              errors are known as syntax errors.
          Ø   A program free from syntax errors may still contain logical errors leading to erroneous output.
          Ø   The process of identifying and removing logical errors is known as debugging.
          Ø   A runtime error may occur during the execution of the program.




         168   Touchpad Computer Science-XI
   165   166   167   168   169   170   171   172   173   174   175