author | anand |
Sun, 07 Nov 2010 01:18:26 +0530 | |
changeset 390 | 69f285b3a5ed |
parent 315 | 7944a4504769 |
child 437 | 0840aa06d2e6 |
permissions | -rw-r--r-- |
315
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
1 |
#+LaTeX_CLASS: beamer |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
2 |
#+LaTeX_CLASS_OPTIONS: [presentation] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
3 |
#+BEAMER_FRAME_LEVEL: 1 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
6 |
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
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 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
8 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
#+LaTeX_CLASS: beamer |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
10 |
#+LaTeX_CLASS_OPTIONS: [presentation] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
11 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
12 |
#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
13 |
#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
14 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
15 |
#+LaTeX_HEADER: \usepackage{listings} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
16 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
17 |
#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries, |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
18 |
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
19 |
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
20 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
21 |
#+TITLE: Accessing parts of arrays |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
22 |
#+AUTHOR: FOSSEE |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
23 |
#+EMAIL: |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
24 |
#+DATE: |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
26 |
#+DESCRIPTION: |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
27 |
#+KEYWORDS: |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
#+LANGUAGE: en |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
30 |
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
32 |
* Outline |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
33 |
- Manipulating one and multi dimensional arrays |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
34 |
- Access and change individual elements |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
35 |
- Access and change rows and columns |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
36 |
- Slicing and striding on arrays to access chunks |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
37 |
- Read images into arrays and manipulations |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
38 |
* Sample Arrays |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
39 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
40 |
In []: A = array([12, 23, 34, 45, 56]) |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
41 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
42 |
In []: C = array([[11, 12, 13, 14, 15], |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
43 |
[21, 22, 23, 24, 25], |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
44 |
[31, 32, 33, 34, 35], |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
45 |
[41, 42, 43, 44, 45], |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
46 |
[51, 52, 53, 54, 55]]) |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
47 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
48 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
49 |
* Question 1 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
50 |
Change the last column of ~C~ to zeroes. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
51 |
* Solution 1 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
52 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
In []: C[:, -1] = 0 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
54 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
55 |
* Question 2 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
56 |
Change ~A~ to ~[11, 12, 13, 14, 15]~. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
57 |
* Solution 2 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
58 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
59 |
In []: A[:] = [11, 12, 13, 14, 15] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
60 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
61 |
* squares.png |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
62 |
#+begin_latex |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
63 |
\begin{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
64 |
\includegraphics[scale=0.6]{squares} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
65 |
\end{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
66 |
#+end_latex |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
67 |
* Question 3 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
68 |
- obtain ~[22, 23]~ from ~C~. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
69 |
- obtain ~[11, 21, 31, 41]~ from ~C~. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
70 |
- obtain ~[21, 31, 41, 0]~. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
71 |
* Solution 3 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
72 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
73 |
In []: C[1, 1:3] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
74 |
In []: C[0:4, 0] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
75 |
In []: C[1:5, 0] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
76 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
77 |
* Question 4 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
78 |
Obtain ~[[23, 24], [33, -34]]~ from ~C~ |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
79 |
* Solution 4 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
80 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
81 |
In []: C[1:3, 2:4] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
82 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
83 |
* Question 5 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
84 |
Obtain the square in the center of the image |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
85 |
* Solution 5 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
86 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
87 |
In []: imshow(I[75:225, 75:225]) |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
88 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
89 |
* Question 6 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
90 |
Obtain the following |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
91 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
92 |
[[12, 0], [42, 0]] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
93 |
[[12, 13, 14], [0, 0, 0]] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
94 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
95 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
96 |
* Solution 6 |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
97 |
#+begin_src python |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
98 |
In []: C[::3, 1::3] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
99 |
In []: C[::4, 1:4] |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
100 |
#+end_src |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
101 |
* Summary |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
102 |
You should now be able to -- |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
103 |
- Manipulate 1D \& Multi dimensional arrays |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
104 |
- Access and change individual elements |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
105 |
- Access and change rows and columns |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
106 |
- Slice and stride on arrays |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
107 |
- Read images into arrays and manipulate them. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
108 |
* Thank you! |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
109 |
#+begin_latex |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
110 |
\begin{block}{} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
111 |
\begin{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
112 |
This spoken tutorial has been produced by the |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
113 |
\textcolor{blue}{FOSSEE} team, which is funded by the |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
114 |
\end{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
115 |
\begin{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
116 |
\textcolor{blue}{National Mission on Education through \\ |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
117 |
Information \& Communication Technology \\ |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
118 |
MHRD, Govt. of India}. |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
119 |
\end{center} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
120 |
\end{block} |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
121 |
#+end_latex |
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
122 |
|
7944a4504769
Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
123 |