author | Amit Sethi |
Tue, 09 Nov 2010 15:10:13 +0530 | |
changeset 416 | 06ac45f4de88 |
parent 406 | a534e9e79599 |
child 418 | 8a42b4203f6d |
permissions | -rw-r--r-- |
321 | 1 |
#+LaTeX_CLASS: beamer |
2 |
#+LaTeX_CLASS_OPTIONS: [presentation] |
|
3 |
#+BEAMER_FRAME_LEVEL: 1 |
|
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 | 6 |
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) |
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 | 20 |
|
416 | 21 |
#+TITLE: Basic Data Types |
321 | 22 |
#+AUTHOR: FOSSEE |
23 |
#+DATE: 2010-09-14 Tue |
|
24 |
#+EMAIL: info@fossee.in |
|
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 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
29 |
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t |
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 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
31 |
|
321 | 32 |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
33 |
* Outline |
321 | 34 |
** Datatypes in Python |
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
35 |
- Numbers |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
36 |
- Boolean |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
37 |
- Sequence |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
38 |
** Operators in Python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
39 |
- Arithmetic Operators |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
40 |
- Boolean Operators |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
41 |
** Python Sequence Datatypes |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
42 |
- list |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
43 |
- string |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
44 |
- tuple |
321 | 45 |
|
46 |
* Numbers |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
47 |
- Integers |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
48 |
- Float |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
49 |
- Complex |
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 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
53 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
54 |
abs(3+4j) |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
55 |
|
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 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
61 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
62 |
- Long |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
63 |
- Large integers numbers are internally stored in python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
64 |
as Long datatype. |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
65 |
|
321 | 66 |
|
67 |
* Boolean |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
68 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
69 |
In []: t=True |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
70 |
In []: f=False |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
71 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
72 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
73 |
* Question 1 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
74 |
- 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
|
75 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
76 |
* Solution 1 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
77 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
78 |
- 3**0.5 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
79 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
80 |
* Question 2 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
81 |
- Is 3**1/2 and 3**0.5 same |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
82 |
* Solution 2 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
83 |
- No,One gives an int answer and the other float |
321 | 84 |
|
85 |
* Sequence Data types |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
86 |
** Properties |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
87 |
- Data in Sequence |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
88 |
- Accessed using Index |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
89 |
** Type |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
90 |
- list |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
91 |
- String |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
92 |
- Tuple |
321 | 93 |
|
94 |
* All are Strings |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
95 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
96 |
k='Single quote' |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
97 |
l="Double quote contain's single quote" |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
98 |
m='''"Contain's both"''' |
321 | 99 |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
100 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
101 |
* Immutabilty Error |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
102 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
103 |
In []: greeting_string[1]='k' |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
104 |
--------------------------------------------------------------------------- |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
105 |
TypeError Traceback (most recent call last) |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
106 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
107 |
/home/amit/st-scripts/basic-data-type/<ipython console> in <module>() |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
108 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
109 |
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
|
110 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
111 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
112 |
* Question 1 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
113 |
- Check if 3 is an element of the list [1,7,5,3,4]. In case |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
114 |
it is change it to 21. |
321 | 115 |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
116 |
* Solution 1 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
117 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
118 |
l=[1,7,5,3,4] |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
119 |
3 in l |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
120 |
l[3]=21 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
121 |
l |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
122 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
123 |
* Question 2 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
124 |
- Convert the string "Elizabeth is queen of england" to |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
125 |
"Elizabeth is queen" |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
126 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
127 |
* Solution 2 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
128 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
129 |
s="Elizabeth is queen of england" |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
130 |
stemp=s.split() |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
131 |
' '.join(stemp[:3]) |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
132 |
#+end_src |
321 | 133 |
* Summary |
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
134 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
135 |
a=73 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
136 |
b=3.14 |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
137 |
c=3+4j |
321 | 138 |
|
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
139 |
#+end_src |
321 | 140 |
* Summary Contd. |
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
141 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
142 |
t=True |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
143 |
f=False |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
144 |
t and f |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
145 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
146 |
* Summary Contd. |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
147 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
148 |
l= [2,1,4,3] |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
149 |
s='hello' |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
150 |
tu=(1,2,3,4) |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
151 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
152 |
* Summary Contd. |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
153 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
154 |
tu[-1] |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
155 |
s[1:-1] |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
156 |
#+end_src |
321 | 157 |
* Summary Contd. |
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
158 |
#+begin_src python |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
159 |
Sorted(l) |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
160 |
#+end_src |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
161 |
* Thank you! |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
162 |
#+begin_latex |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
163 |
\begin{block}{} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
164 |
\begin{center} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
165 |
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
|
166 |
\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
|
167 |
\end{center} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
168 |
\begin{center} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
169 |
\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
|
170 |
Information \& Communication Technology \\ |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
171 |
MHRD, Govt. of India}. |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
172 |
\end{center} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
173 |
\end{block} |
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
174 |
#+end_latex |
321 | 175 |
|
176 |
||
406
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
177 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
178 |
|
a534e9e79599
Completed basic data type based on review and improved on slides
Amit Sethi
parents:
337
diff
changeset
|
179 |