basic-data-type/slides.org
changeset 412 bb45826efe74
parent 406 a534e9e79599
child 418 8a42b4203f6d
equal deleted inserted replaced
411:e227c45b0c3f 412:bb45826efe74
    19 #+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
    19 #+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
    20 
    20 
    21 #+TITLE: Plotting Data 
    21 #+TITLE: Plotting Data 
    22 #+AUTHOR: FOSSEE
    22 #+AUTHOR: FOSSEE
    23 #+DATE: 2010-09-14 Tue
    23 #+DATE: 2010-09-14 Tue
    24 #+EMAIL:     info@fossee.in
    24 #+EMAIL: info@fossee.in
    25 
    25 
    26 #+DESCRIPTION: 
    26 #+DESCRIPTION: 
    27 #+KEYWORDS: 
    27 #+KEYWORDS: 
    28 #+LANGUAGE:  en
    28 #+LANGUAGE:  en
    29 #+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
    29 #+OPTIONS:   H:1 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
    30 #+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
    30 #+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
    31 
    31 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
    32 
    32 
    33 * Outline 
    33 * Outline 
    34 ** Datatypes in Python
    34 ** Datatypes in Python
    35     - Numbers
    35 *** Numbers
    36     - Boolean
    36 *** Boolean
    37     - Sequence
    37 *** Sequence
    38 **  Operators in Python
    38 ** Operators in Python
    39     - Arithmetic Operators
    39 *** Arithmetic Operators
    40     - Boolean Operators
    40 *** Boolean Operators
    41 ** Python Sequence Datatypes
    41 ** Python Sequence Datatypes
    42    - list
    42 *** list
    43    - string
    43 *** string
    44    - tuple
    44 *** tuple
    45 
    45 
    46 * Numbers
    46 * Numbers
    47   - Integers
    47   - int
    48   - Float
    48   - float
    49   - Complex
    49   - complex
    50 * Question 1
    50 * Question 1
    51    - Find the absolute value of 3+4j 
    51    - Find the absolute value of 3+4j 
    52 * Solution 1
    52 * Solution 1
    53 
    53   #+begin_src python
    54         abs(3+4j)
    54     abs(3+4j)
    55 
    55   #+end_src python
    56 * Question 2
    56 * Question 2
    57   - What is the datatype of number 999999999999999999? Is it
    57   - What is the datatype of number 999999999999999999? Is it
    58 not int?
    58 not int?
    59 
    59 
    60 * Solution 2
    60 * Solution 2
    61         
    61   - Long
    62         - Long
    62   - Large integers numbers are internally stored in python as Long
    63         - Large integers numbers are internally stored in python
    63     datatype.
    64         as Long datatype.  
       
    65 
    64 
    66 
    65 
    67 * Boolean
    66 * Boolean
    68   #+begin_src python
    67   #+begin_src python
    69     In []: t=True
    68     In []: t=True
    70     In []: f=False
    69     In []: f=False
    71   #+end_src
    70   #+end_src
    72 
    71 
    73 * Question 1
    72 * Question 3
    74   - Using python find sqaure root of 3?
    73   - Using python find sqaure root of 3?
    75 
    74 
    76 * Solution 1
    75 * Solution 3
    77 
    76 
    78   - 3**0.5
    77   - 3**0.5
    79 
    78 
    80 * Question 2
    79 * Question 4
    81   - Is 3**1/2 and 3**0.5 same
    80   - Is 3**1/2 and 3**0.5 same
    82 * Solution 2
    81 * Solution 4
    83   - No,One gives an int answer and the other float        
    82   - No,One gives an int answer and the other float        
    84 
    83 
    85 * Sequence Data types
    84 * Sequence Data types
    86 ** Properties
    85 ** Properties
    87  - Data in Sequence 
    86  - Data in Sequence 
    91  - String
    90  - String
    92  - Tuple
    91  - Tuple
    93 
    92 
    94 * All are Strings
    93 * All are Strings
    95    #+begin_src python 
    94    #+begin_src python 
    96       k='Single quote'
    95       k = 'Single quote'
    97       l="Double quote contain's single quote"
    96       l = "Double quote contain's single quote"
    98       m='''"Contain's both"'''
    97       m = '''"Contain's both"'''
    99 
    98 
   100     #+end_src 
    99     #+end_src 
   101 * Immutabilty Error
   100 * Immutabilty Error
   102    #+begin_src python
   101    #+begin_src python
   103       In []: greeting_string[1]='k'
   102       In []: greeting_string[1]='k'
   104       ---------------------------------------------------------------------------
   103       -------------------------------------------------------
   105       TypeError                                 Traceback (most recent call       last)
   104       TypeError           Traceback (most recent call last)
   106 
   105 
   107       /home/amit/st-scripts/basic-data-type/<ipython console> in <module>()
   106       /home/fossee/<ipython console> in <module>()
   108 
   107 
   109       TypeError: 'str' object does not support item assignment
   108       TypeError: 'str' object does not support item assignment
   110    #+end_src 
   109    #+end_src 
   111 
   110 
   112 * Question 1
   111 * Question 5
   113    - Check if 3 is an element of the list [1,7,5,3,4]. In case
   112   Check if 3 is an element of the list [1,7,5,3,4]. In case it is
   114 it is change it to 21.
   113 change it to 21.
   115 
   114 
   116 * Solution 1
   115 * Solution 5
   117      #+begin_src python
   116      #+begin_src python
   118         l=[1,7,5,3,4]
   117         l=[1,7,5,3,4]
   119         3 in l
   118         3 in l
   120         l[3]=21
   119         l[3]=21
   121         l
   120         l
   122      #+end_src
   121      #+end_src
   123 * Question 2
   122 * Question 6
   124   - Convert the string "Elizabeth is queen of england" to
   123   Convert the string ~"Elizabeth is queen of england"~ to ~"Elizabeth is
   125 "Elizabeth is queen"
   124 queen"~
   126 
   125 
   127 * Solution 2
   126 * Solution 6
   128      #+begin_src python
   127      #+begin_src python
   129     s="Elizabeth is queen of england"                                                                                                                 
   128     s = "Elizabeth is queen of england"                                                                                                                 
   130     stemp=s.split()                                                                                                                                   
   129     stemp = s.split()                                                                                                                                   
   131     ' '.join(stemp[:3])                                                                                                                               
   130     ' '.join(stemp[:3])                                                                                                                               
   132     #+end_src 
   131     #+end_src 
   133 * Summary 
   132 * Summary 
   134    #+begin_src python 
   133   - Number Datatypes -- integer,float and complex 
   135     a=73
   134   - Boolean and datatype and operators
   136     b=3.14
   135   - Sequence data types -- List, String and Tuple
   137     c=3+4j
   136   - Accesing sequence
   138 
   137   - Slicing sequences
   139    #+end_src
   138   - Finding length, sorting and reversing operations on sequences
   140 * Summary Contd.
   139   - Immutability
   141    #+begin_src python
       
   142      t=True
       
   143      f=False
       
   144      t and f
       
   145    #+end_src
       
   146 * Summary Contd.
       
   147    #+begin_src python 
       
   148      l= [2,1,4,3]
       
   149      s='hello'
       
   150      tu=(1,2,3,4)
       
   151    #+end_src
       
   152 * Summary Contd.
       
   153    #+begin_src python 
       
   154      tu[-1]
       
   155      s[1:-1]
       
   156    #+end_src
       
   157 * Summary Contd.
       
   158    #+begin_src python  
       
   159      Sorted(l)
       
   160    #+end_src
       
   161 * Thank you!
   140 * Thank you!
   162 #+begin_latex
   141 #+begin_latex
   163   \begin{block}{}
   142   \begin{block}{}
   164   \begin{center}
   143   \begin{center}
   165   This spoken tutorial has been produced by the
   144   This spoken tutorial has been produced by the