basic-data-type/slides.org
author Puneeth Chaganti <punchagan@fossee.in>
Tue, 09 Nov 2010 14:57:08 +0530
changeset 412 bb45826efe74
parent 406 a534e9e79599
child 418 8a42b4203f6d
permissions -rw-r--r--
Changes to basic data-types.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     1
#+LaTeX_CLASS: beamer
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     2
#+LaTeX_CLASS_OPTIONS: [presentation]
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     3
#+BEAMER_FRAME_LEVEL: 1
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     4
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
     5
#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     6
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
     7
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
     8
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
     9
#+LaTeX_CLASS: beamer
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    10
#+LaTeX_CLASS_OPTIONS: [presentation]
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    11
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    12
#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    13
#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    14
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    15
#+LaTeX_HEADER: \usepackage{listings}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    16
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    17
#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    18
#+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    19
#+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    20
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    21
#+TITLE: Plotting Data 
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    22
#+AUTHOR: FOSSEE
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    23
#+DATE: 2010-09-14 Tue
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    24
#+EMAIL: info@fossee.in
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    25
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    26
#+DESCRIPTION: 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    27
#+KEYWORDS: 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    28
#+LANGUAGE:  en
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    29
#+OPTIONS:   H:1 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    30
#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    31
#+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    32
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    33
* Outline 
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    34
** Datatypes in Python
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    35
*** Numbers
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    36
*** Boolean
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    37
*** Sequence
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    38
** Operators in Python
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    39
*** Arithmetic Operators
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    40
*** Boolean Operators
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    41
** Python Sequence Datatypes
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    42
*** list
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    43
*** string
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    44
*** tuple
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    45
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    46
* Numbers
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    47
  - int
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    48
  - float
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    49
  - complex
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    50
* Question 1
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    51
   - Find the absolute value of 3+4j 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    52
* Solution 1
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    53
  #+begin_src python
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    54
    abs(3+4j)
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    55
  #+end_src python
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    56
* Question 2
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    57
  - What is the datatype of number 999999999999999999? Is it
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    58
not int?
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    59
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    60
* Solution 2
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    61
  - Long
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    62
  - Large integers numbers are internally stored in python as Long
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    63
    datatype.
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    64
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    65
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    66
* Boolean
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    67
  #+begin_src python
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    68
    In []: t=True
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    69
    In []: f=False
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    70
  #+end_src
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    71
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    72
* Question 3
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    73
  - Using python find sqaure root of 3?
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    74
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    75
* Solution 3
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    76
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    77
  - 3**0.5
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    78
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    79
* Question 4
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    80
  - Is 3**1/2 and 3**0.5 same
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    81
* Solution 4
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    82
  - No,One gives an int answer and the other float        
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    83
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    84
* Sequence Data types
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    85
** Properties
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    86
 - Data in Sequence 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    87
 - Accessed using Index
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    88
** Type
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    89
 - list
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    90
 - String
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    91
 - Tuple
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    92
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    93
* All are Strings
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    94
   #+begin_src python 
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    95
      k = 'Single quote'
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    96
      l = "Double quote contain's single quote"
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
    97
      m = '''"Contain's both"'''
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
    98
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
    99
    #+end_src 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   100
* Immutabilty Error
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   101
   #+begin_src python
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   102
      In []: greeting_string[1]='k'
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   103
      -------------------------------------------------------
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   104
      TypeError           Traceback (most recent call last)
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   105
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   106
      /home/fossee/<ipython console> in <module>()
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   107
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   108
      TypeError: 'str' object does not support item assignment
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   109
   #+end_src 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   110
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   111
* Question 5
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   112
  Check if 3 is an element of the list [1,7,5,3,4]. In case it is
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   113
change it to 21.
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
   114
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   115
* Solution 5
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   116
     #+begin_src python
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   117
        l=[1,7,5,3,4]
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   118
        3 in l
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   119
        l[3]=21
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   120
        l
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   121
     #+end_src
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   122
* Question 6
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   123
  Convert the string ~"Elizabeth is queen of england"~ to ~"Elizabeth is
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   124
queen"~
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   125
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   126
* Solution 6
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   127
     #+begin_src python
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   128
    s = "Elizabeth is queen of england"                                                                                                                 
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   129
    stemp = s.split()                                                                                                                                   
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   130
    ' '.join(stemp[:3])                                                                                                                               
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   131
    #+end_src 
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
   132
* Summary 
412
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   133
  - Number Datatypes -- integer,float and complex 
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   134
  - Boolean and datatype and operators
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   135
  - Sequence data types -- List, String and Tuple
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   136
  - Accesing sequence
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   137
  - Slicing sequences
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   138
  - Finding length, sorting and reversing operations on sequences
bb45826efe74 Changes to basic data-types.
Puneeth Chaganti <punchagan@fossee.in>
parents: 406
diff changeset
   139
  - Immutability
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   140
* Thank you!
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   141
#+begin_latex
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   142
  \begin{block}{}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   143
  \begin{center}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   144
  This spoken tutorial has been produced by the
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   145
  \textcolor{blue}{FOSSEE} team, which is funded by the 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   146
  \end{center}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   147
  \begin{center}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   148
    \textcolor{blue}{National Mission on Education through \\
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   149
      Information \& Communication Technology \\ 
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   150
      MHRD, Govt. of India}.
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   151
  \end{center}  
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   152
  \end{block}
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   153
#+end_latex
321
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
   154
2e49b1b72996 adding questions for all other LO needs to be cleaned
amit
parents:
diff changeset
   155
406
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   156
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   157
a534e9e79599 Completed basic data type based on review and improved on slides
Amit Sethi
parents: 337
diff changeset
   158