From 8d719a699d597c2af29a377df294066c356b1519 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 8 Nov 2010 11:39:07 +0530 Subject: Changes to using sage. --- using-sage/script.rst | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/using-sage/script.rst b/using-sage/script.rst index 21c6af2..e32ac0d 100644 --- a/using-sage/script.rst +++ b/using-sage/script.rst @@ -28,12 +28,8 @@ Hello Friends. Welcome to this tutorial on using Sage. {{{ show the slide with outline }}} -In this tutorial we shall quickly look at a few examples of the areas -(name the areas, here) in which Sage can be used and how it can be -used. - -.. #[[Anoop: add name of areas and further introduction if needed for - a smooth switch]] +In this tutorial we shall quickly look at a few examples of using Sage +for Linear Algebra, Calculus, Graph Theory and Number theory. {{{ show the slide with Calculus outline }}} @@ -62,9 +58,7 @@ the positive side. To find the limit from the negative side, we say, :: - lim(1/x, x=0, dir='above') - -.. #[[Anoop: both the above codes are going the same thing isn't it?]] + lim(1/x, x=0, dir='below') Let us now see how to differentiate, using Sage. We shall find the differential of the expression ``exp(sin(x^2))/x`` w.r.t ``x``. We -- cgit From 6adf074027964e36420449e4347bf9045868b7d2 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Tue, 9 Nov 2010 10:54:53 +0530 Subject: Moved plotui to using-plot-interactively. --- using-plot-interactively/buttons.png | Bin 0 -> 5214 bytes using-plot-interactively/move.png | Bin 0 -> 606 bytes using-plot-interactively/quickref.tex | 14 +++ using-plot-interactively/save.png | Bin 0 -> 676 bytes using-plot-interactively/script.rst | 212 ++++++++++++++++++++++++++++++++++ using-plot-interactively/slides.tex | 71 ++++++++++++ using-plot-interactively/zoom.png | Bin 0 -> 947 bytes 7 files changed, 297 insertions(+) create mode 100644 using-plot-interactively/buttons.png create mode 100644 using-plot-interactively/move.png create mode 100644 using-plot-interactively/quickref.tex create mode 100644 using-plot-interactively/save.png create mode 100644 using-plot-interactively/script.rst create mode 100644 using-plot-interactively/slides.tex create mode 100644 using-plot-interactively/zoom.png diff --git a/using-plot-interactively/buttons.png b/using-plot-interactively/buttons.png new file mode 100644 index 0000000..7b39d24 Binary files /dev/null and b/using-plot-interactively/buttons.png differ diff --git a/using-plot-interactively/move.png b/using-plot-interactively/move.png new file mode 100644 index 0000000..538ed1f Binary files /dev/null and b/using-plot-interactively/move.png differ diff --git a/using-plot-interactively/quickref.tex b/using-plot-interactively/quickref.tex new file mode 100644 index 0000000..6f0451f --- /dev/null +++ b/using-plot-interactively/quickref.tex @@ -0,0 +1,14 @@ +Creating a linear array:\\ +{\ex \lstinline| x = linspace(0, 2*pi, 50)|} + +Plotting two variables:\\ +{\ex \lstinline| plot(x, sin(x))|} + +Saving Plot\\ +{\includegraphics[width=60mm]{save.png}} + +Zooming into a part of the plot\\ +{\includegraphics[width=60mm]{zoom.png}} + +Move the plot\\ +{\includegraphics[width=60mm]{move.png}} diff --git a/using-plot-interactively/save.png b/using-plot-interactively/save.png new file mode 100644 index 0000000..b1a6757 Binary files /dev/null and b/using-plot-interactively/save.png differ diff --git a/using-plot-interactively/script.rst b/using-plot-interactively/script.rst new file mode 100644 index 0000000..21af31b --- /dev/null +++ b/using-plot-interactively/script.rst @@ -0,0 +1,212 @@ +.. Objectives +.. ---------- + +.. By the end of this tutorial you will -- + +.. 1. Create simple plots of mathematical functions +.. #. Use the Figure window to study plots better + + + +.. Prerequisites +.. ------------- + +.. Installation of required tools +.. Ipython + +.. Author : Amit Sethi + Internal Reviewer : + External Reviewer : + Checklist OK? : [2010-10-05] + +Script +------- + + +Hello and welcome to the tutorial on creating simple plots using +Python.This tutorial is presented by the Fossee group. +{{{ Show the Title Slide }}} + +I hope you have IPython running on your computer. + +In this tutorial we will look at plot command and also how to study +the plot using the UI. + +{{{ Show Outline Slide }}} + +Lets start ipython on your shell, type :: + + $ipython -pylab + + +Pylab is a python library which provides plotting functionality.It +also provides many other important mathematical and scientific +functions. After running IPython -pylab in your shell if at the top of +the result of this command, you see something like :: + + + `ERROR: matplotlib could NOT be imported! Starting normal + IPython.` + + +{{{ Slide with Error written on it }}} + + + + +Then you have to install matplotlib and run this command again. + +Now type in your ipython shell :: + + In[]: linpace? + + + +as the documentation says, it returns `num` evenly spaced samples, +calculated over the interval start and stop. To illustrate this, lets +do it form 1 to 100 and try 100 points. :: + + In[]: linspace(1,100,100) + +As you can see a sequence of numbers from 1 to 100 appears. + +Now lets try 200 points between 0 and 1 you do this by typing :: + + + In[]: linspace(0,1,200) + +0 for start , 1 for stop and 200 for no of points. In linspace +the start and stop points can be integers, decimals , or +constants. Let's try and get 100 points between -pi to pi. Type :: + + In[]: p = linspace(-pi,pi,100) + + +'pi' here is constant defined by pylab. Save this to the variable, p +. + +If you now :: + + In[]: len(p) + +You will get the no. of points. len function gives the no of elements +of a sequence. + + +Let's try and plot a cosine curve between -pi and pi using these +points. Simply type :: + + + In[]: plot(p,cos(points)) + +Here cos(points) gets the cosine value at every corresponding point to +p. + + +We can also save cos(points) to variable cosine and plot it using +plot.:: + + In[]: cosine=cos(points) + + In[]: plot(p,cosine) + + + +Now do :: + + In[]: clf() + +this will clear the plot. + +This is done because any other plot we try to make shall come on the +same drawing area. As we do not wish to clutter the area with +overlaid plots , we just clear it with clf(). Now lets try a sine +plot. :: + + + In []: plot(p,sin(p)) + + + + +The Window on which the plot appears can be used to study it better. + +{{{ Show the slide with all the buttons on it }}} + +First of all moving the mouse around gives us the point where mouse +points at. + +Also we have some buttons the right most among them is +for saving the file. + +Just click on it specifying the name of the file. We will save the plot +by the name sin_curve in pdf format. + + + +{{{ Action corelating with the words }}} + +As you can see I can specify format of file from the dropdown. + +Formats like png ,eps ,pdf, ps are available. + +Left to the save button is the slider button to specify the margins. + +{{{ Action corelating with the words }}} + +Left to this is zoom button to zoom into the plot. Just specify the +region to zoom into. +The button left to it can be used to move the axes of the plot. + +{{{ Action corelating with the words }}} + +The next two buttons with a left and right arrow icons change the state of the +plot and take it to the previous state it was in. It more or less acts like a +back and forward button in the browser. + +{{{ Action corelating with the words }}} + +The last one is 'home' referring to the initial plot. + +{{{ Action corelating with the words}}} + + + +{{{ Summary Slide }}} + + +In this tutorial we have looked at + +1. Starting Ipython with pylab + +2. Using linspace function to create `num` equaly spaced points in a region. + +3. Finding length of sequnces using len. + +4. Plotting mathematical functions using plot. + +4. Clearing drawing area using clf + +5. Using the UI of plot for studying it better . Using functionalities like save , zoom and moving the plots on x and y axis + + + + + +{{{ Show the "sponsored by FOSSEE" slide }}} + + + +This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India + + + + Hope you have enjoyed and found it useful. + + Thankyou + + + +Author : Amit Sethi +Internal Reviewer : +Internal Reviewer 2 : diff --git a/using-plot-interactively/slides.tex b/using-plot-interactively/slides.tex new file mode 100644 index 0000000..6999f43 --- /dev/null +++ b/using-plot-interactively/slides.tex @@ -0,0 +1,71 @@ +% Created 2010-10-20 Wed 21:57 +\documentclass[presentation]{beamer} +\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent} +\usepackage[latin1]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage{longtable} +\usepackage{float} +\usepackage{wrapfig} +\usepackage{soul} +\usepackage{amssymb} +\usepackage{hyperref} + + +\title{Plotting Data } +\author{FOSSEE} +\date{2010-09-14 Tue} + +\begin{document} + +\maketitle + +\begin{frame} +\frametitle{Tutorial Plan} +\label{sec-1} +\begin{itemize} + +\item Creating a simple plot\\ +\label{sec-1.1}% +\item Use the buttons on window to study the plot\\ +\label{sec-1.2}% +\end{itemize} % ends low level +\end{frame} +\begin{frame} +\frametitle{Error if Ipython not installed} +\label{sec-2} +\begin{itemize} + +\item `ERROR: matplotlib could NOT be imported! Starting normal IPython.`\\ +\label{sec-2.1}% +\end{itemize} % ends low level +\end{frame} +\begin{frame} +\frametitle{Plot UI} +\label{sec-3} +\begin{frame} + \begin{center} + \includegraphics[height=1.0in,width=4.2in]{buttons.png} + \end{center} +\end{frame} + +\frametitle{Summary} +\label{sec-4} +\begin{itemize} + +\item Start Ipython with pylab\\ +\label{sec-4.1}% +\item Using linspace\\ +\label{sec-4.2}% +\item Finding length of sequnces using len.\\ +\label{sec-4.3}% +\item Plotting mathematical functions using plot.\\ +\label{sec-4.4}% +\item Clearing drawing area using clf\\ +\label{sec-4.5}% +\item Using the UI of plot\\ +\label{sec-4.6}% +\end{itemize} % ends low level +\end{frame} + +\end{document} diff --git a/using-plot-interactively/zoom.png b/using-plot-interactively/zoom.png new file mode 100644 index 0000000..c1a7fdf Binary files /dev/null and b/using-plot-interactively/zoom.png differ -- cgit From a7653f741cd41e9b00c9c1718ad2c2a0107ee191 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Tue, 9 Nov 2010 10:56:40 +0530 Subject: Minor changes to loops, input-output and advanced functions. --- advanced-features-functions/script.rst | 12 +- input_output/script.rst | 29 +++-- loops/script.rst | 22 ++-- plotui/buttons.png | Bin 5214 -> 0 bytes plotui/move.png | Bin 606 -> 0 bytes plotui/quickref.tex | 14 --- plotui/save.png | Bin 676 -> 0 bytes plotui/script.rst | 212 --------------------------------- plotui/slides.tex | 71 ----------- plotui/zoom.png | Bin 947 -> 0 bytes 10 files changed, 27 insertions(+), 333 deletions(-) delete mode 100644 plotui/buttons.png delete mode 100644 plotui/move.png delete mode 100644 plotui/quickref.tex delete mode 100644 plotui/save.png delete mode 100644 plotui/script.rst delete mode 100644 plotui/slides.tex delete mode 100644 plotui/zoom.png diff --git a/advanced-features-functions/script.rst b/advanced-features-functions/script.rst index 0abae54..6e49c44 100644 --- a/advanced-features-functions/script.rst +++ b/advanced-features-functions/script.rst @@ -169,7 +169,8 @@ Please, pause the video here. Do the exercise and then continue. welcome() -Let us now learn what keyword arguments are. +Let us now learn what keyword arguments or named arguments are. We +shall refer to them as keyword arguments, henceforth. {{{ show a slide with examples using keyword arguments. }}} @@ -185,14 +186,6 @@ Let us now learn what keyword arguments are. pie(science.values(), labels = science.keys()) -.. #[[Anoop: I think it will better to introduce keyword arguments as - keyword/named arguments, as the keyword term was quite confusing - for me, so can be for someone who already know certain - jargon's/concepts, also it would be good to tell them that these - are different from keywords in programming languages, explicit is - better than implicit, and probably you could also tell them that - from now on we will refer to it as just keyword arguments]] - When you are calling functions in Python, you don't need to remember the order in which to pass the arguments. Instead, you can use the name of the argument to pass it a value. This slide shows a few @@ -249,7 +242,6 @@ with it. .. #[punch: Need to decide, exactly what to put here. Reviewer comments .. welcome.] - {{{ switch to slide showing classes of functions in pylab, scipy }}} .. #[[Anoop: slide missing]] diff --git a/input_output/script.rst b/input_output/script.rst index bcac6e9..799ff17 100644 --- a/input_output/script.rst +++ b/input_output/script.rst @@ -12,7 +12,7 @@ .. 1. Loops .. Author : Nishanth Amuluru - Internal Reviewer : + Internal Reviewer : Puneeth External Reviewer : Checklist OK? : [2010-10-05] @@ -26,10 +26,10 @@ Hello friends and welcome to the tutorial on Input/Output {{{ Show the slide containing the outline slide }}} Input and Output are used in almost every program we use. -In this tutorial, we shall learn +In this tutorial, we shall learn how to - * Outputting data - * Taking input from the user + * Output data + * Take input from the user type :: @@ -38,7 +38,7 @@ type a print a -print a prints the value of a which is obvious. +``print a``, obviously, is printing the value of ``a``. As you can see, even when you type just a, the value of a is shown. But there is a difference. @@ -57,10 +57,12 @@ While typing print b prints the string and hence the newline. Moreover when we type just a, the value a is shown only in interactive mode and does not have any effect on the program while running it as a script. +.. #[punch: I think we could show that?] + We shall look at different ways of outputting the data. -print statement also accepts the syntax of C's printf statement. -Various arguments can be passed to print using modifiers. +``print`` statement also accepts the syntax of C's ``printf`` statement. +Various arguments can be passed to ``print`` using modifiers. type :: @@ -69,7 +71,8 @@ type z = "zed" print "x is %2.1f y is %d z is %s"%(x,y) -As you can see, the values of x and y are substituted in place of %2.1f and %d +As you can see, the values of x and y are substituted in place of +``%2.1f`` and ``%d`` {{{ Pause here and try out the following exercises }}} @@ -77,12 +80,12 @@ As you can see, the values of x and y are substituted in place of %2.1f and %d {{{ continue from paused state }}} -We see that the int value of x and float value of y are printed corresponding -to the modifiers used in the print statement. +We see that the ``int`` value of x and ``float`` value of y are +printed corresponding to the modifiers used in the print statement. -We can also see that print statement prints a new line character at the end of -line, everytime it is called. This can be suppressed by using a "," at the end -print statement. +We can also see that ``print`` statement prints a new line character +at the end of the line, everytime it is called. This can be suppressed +by using a "," at the end ``print`` statement. Let us see this by typing out following code on an editor as print_example.py diff --git a/loops/script.rst b/loops/script.rst index 2957e25..5204596 100644 --- a/loops/script.rst +++ b/loops/script.rst @@ -31,15 +31,14 @@ Hello Friends. Welcome to the tutorial on loops in Python. {{{ Show the outline slide }}} In this tutorial, we shall look at ``while`` and ``for`` loops. We -shall then look at the ``break``, ``continue`` and ``pass`` keywords -and how to use them. +shall then look at how to break out of them, or skip some iterations +in loops. .. #[[Anoop: for loop is a pre-requisite and has been already covered, so i think our emphasize can be on while loops]] -.. #[[Anoop: Instead of saying we will learn keywords pass, break and - continue, I think it is better to tell them that we will learn more - about loops]] +.. #[[punch: I think, we should have both of them. It gives a better +.. context and comparison.] {{{ switch to the ipython terminal }}} @@ -144,8 +143,8 @@ iteration and continue to the end of this iteration. .. #[[Anoop: should add slides for break, continue, pass]] Say, we wish to print the squares of all the odd numbers below 10, -which are not multiples of 3, we would modify the for loop as follows. -:: +which are not multiples of 3, we would modify the ``for`` loop as +follows. :: for n in range(1, 10, 2): if n%3 == 0: @@ -157,12 +156,9 @@ Following is an exercise that you must do. {{{ switch to next slide }}} -%%3%%Using the ``continue`` keyword modify the ``for`` loop to print -the squares of even numbers below 10, to print the squares of only -multiples of 4. (Do not modify the range function call.) - -.. #[[Anoop: can you be more explicit/specific on do no modify say we - can ask them to use range(2, 10, 2) and solve the problem]] +%%3%%Using the ``continue`` keyword modify the ``for`` loop, with the +``range(2, 10, 2)``, to print the squares of even numbers below 10, to +print the squares of only multiples of 4. Please, pause the video here. Do the exercise and then continue. diff --git a/plotui/buttons.png b/plotui/buttons.png deleted file mode 100644 index 7b39d24..0000000 Binary files a/plotui/buttons.png and /dev/null differ diff --git a/plotui/move.png b/plotui/move.png deleted file mode 100644 index 538ed1f..0000000 Binary files a/plotui/move.png and /dev/null differ diff --git a/plotui/quickref.tex b/plotui/quickref.tex deleted file mode 100644 index 6f0451f..0000000 --- a/plotui/quickref.tex +++ /dev/null @@ -1,14 +0,0 @@ -Creating a linear array:\\ -{\ex \lstinline| x = linspace(0, 2*pi, 50)|} - -Plotting two variables:\\ -{\ex \lstinline| plot(x, sin(x))|} - -Saving Plot\\ -{\includegraphics[width=60mm]{save.png}} - -Zooming into a part of the plot\\ -{\includegraphics[width=60mm]{zoom.png}} - -Move the plot\\ -{\includegraphics[width=60mm]{move.png}} diff --git a/plotui/save.png b/plotui/save.png deleted file mode 100644 index b1a6757..0000000 Binary files a/plotui/save.png and /dev/null differ diff --git a/plotui/script.rst b/plotui/script.rst deleted file mode 100644 index 21af31b..0000000 --- a/plotui/script.rst +++ /dev/null @@ -1,212 +0,0 @@ -.. Objectives -.. ---------- - -.. By the end of this tutorial you will -- - -.. 1. Create simple plots of mathematical functions -.. #. Use the Figure window to study plots better - - - -.. Prerequisites -.. ------------- - -.. Installation of required tools -.. Ipython - -.. Author : Amit Sethi - Internal Reviewer : - External Reviewer : - Checklist OK? : [2010-10-05] - -Script -------- - - -Hello and welcome to the tutorial on creating simple plots using -Python.This tutorial is presented by the Fossee group. -{{{ Show the Title Slide }}} - -I hope you have IPython running on your computer. - -In this tutorial we will look at plot command and also how to study -the plot using the UI. - -{{{ Show Outline Slide }}} - -Lets start ipython on your shell, type :: - - $ipython -pylab - - -Pylab is a python library which provides plotting functionality.It -also provides many other important mathematical and scientific -functions. After running IPython -pylab in your shell if at the top of -the result of this command, you see something like :: - - - `ERROR: matplotlib could NOT be imported! Starting normal - IPython.` - - -{{{ Slide with Error written on it }}} - - - - -Then you have to install matplotlib and run this command again. - -Now type in your ipython shell :: - - In[]: linpace? - - - -as the documentation says, it returns `num` evenly spaced samples, -calculated over the interval start and stop. To illustrate this, lets -do it form 1 to 100 and try 100 points. :: - - In[]: linspace(1,100,100) - -As you can see a sequence of numbers from 1 to 100 appears. - -Now lets try 200 points between 0 and 1 you do this by typing :: - - - In[]: linspace(0,1,200) - -0 for start , 1 for stop and 200 for no of points. In linspace -the start and stop points can be integers, decimals , or -constants. Let's try and get 100 points between -pi to pi. Type :: - - In[]: p = linspace(-pi,pi,100) - - -'pi' here is constant defined by pylab. Save this to the variable, p -. - -If you now :: - - In[]: len(p) - -You will get the no. of points. len function gives the no of elements -of a sequence. - - -Let's try and plot a cosine curve between -pi and pi using these -points. Simply type :: - - - In[]: plot(p,cos(points)) - -Here cos(points) gets the cosine value at every corresponding point to -p. - - -We can also save cos(points) to variable cosine and plot it using -plot.:: - - In[]: cosine=cos(points) - - In[]: plot(p,cosine) - - - -Now do :: - - In[]: clf() - -this will clear the plot. - -This is done because any other plot we try to make shall come on the -same drawing area. As we do not wish to clutter the area with -overlaid plots , we just clear it with clf(). Now lets try a sine -plot. :: - - - In []: plot(p,sin(p)) - - - - -The Window on which the plot appears can be used to study it better. - -{{{ Show the slide with all the buttons on it }}} - -First of all moving the mouse around gives us the point where mouse -points at. - -Also we have some buttons the right most among them is -for saving the file. - -Just click on it specifying the name of the file. We will save the plot -by the name sin_curve in pdf format. - - - -{{{ Action corelating with the words }}} - -As you can see I can specify format of file from the dropdown. - -Formats like png ,eps ,pdf, ps are available. - -Left to the save button is the slider button to specify the margins. - -{{{ Action corelating with the words }}} - -Left to this is zoom button to zoom into the plot. Just specify the -region to zoom into. -The button left to it can be used to move the axes of the plot. - -{{{ Action corelating with the words }}} - -The next two buttons with a left and right arrow icons change the state of the -plot and take it to the previous state it was in. It more or less acts like a -back and forward button in the browser. - -{{{ Action corelating with the words }}} - -The last one is 'home' referring to the initial plot. - -{{{ Action corelating with the words}}} - - - -{{{ Summary Slide }}} - - -In this tutorial we have looked at - -1. Starting Ipython with pylab - -2. Using linspace function to create `num` equaly spaced points in a region. - -3. Finding length of sequnces using len. - -4. Plotting mathematical functions using plot. - -4. Clearing drawing area using clf - -5. Using the UI of plot for studying it better . Using functionalities like save , zoom and moving the plots on x and y axis - - - - - -{{{ Show the "sponsored by FOSSEE" slide }}} - - - -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India - - - - Hope you have enjoyed and found it useful. - - Thankyou - - - -Author : Amit Sethi -Internal Reviewer : -Internal Reviewer 2 : diff --git a/plotui/slides.tex b/plotui/slides.tex deleted file mode 100644 index 6999f43..0000000 --- a/plotui/slides.tex +++ /dev/null @@ -1,71 +0,0 @@ -% Created 2010-10-20 Wed 21:57 -\documentclass[presentation]{beamer} -\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent} -\usepackage[latin1]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{graphicx} -\usepackage{longtable} -\usepackage{float} -\usepackage{wrapfig} -\usepackage{soul} -\usepackage{amssymb} -\usepackage{hyperref} - - -\title{Plotting Data } -\author{FOSSEE} -\date{2010-09-14 Tue} - -\begin{document} - -\maketitle - -\begin{frame} -\frametitle{Tutorial Plan} -\label{sec-1} -\begin{itemize} - -\item Creating a simple plot\\ -\label{sec-1.1}% -\item Use the buttons on window to study the plot\\ -\label{sec-1.2}% -\end{itemize} % ends low level -\end{frame} -\begin{frame} -\frametitle{Error if Ipython not installed} -\label{sec-2} -\begin{itemize} - -\item `ERROR: matplotlib could NOT be imported! Starting normal IPython.`\\ -\label{sec-2.1}% -\end{itemize} % ends low level -\end{frame} -\begin{frame} -\frametitle{Plot UI} -\label{sec-3} -\begin{frame} - \begin{center} - \includegraphics[height=1.0in,width=4.2in]{buttons.png} - \end{center} -\end{frame} - -\frametitle{Summary} -\label{sec-4} -\begin{itemize} - -\item Start Ipython with pylab\\ -\label{sec-4.1}% -\item Using linspace\\ -\label{sec-4.2}% -\item Finding length of sequnces using len.\\ -\label{sec-4.3}% -\item Plotting mathematical functions using plot.\\ -\label{sec-4.4}% -\item Clearing drawing area using clf\\ -\label{sec-4.5}% -\item Using the UI of plot\\ -\label{sec-4.6}% -\end{itemize} % ends low level -\end{frame} - -\end{document} diff --git a/plotui/zoom.png b/plotui/zoom.png deleted file mode 100644 index c1a7fdf..0000000 Binary files a/plotui/zoom.png and /dev/null differ -- cgit From 3ccaf26be2e2321ce074ea72448fb4240a22523e Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Tue, 9 Nov 2010 14:57:08 +0530 Subject: Changes to basic data-types. --- basic-data-type/script.rst | 89 +++++----------------- basic-data-type/slides.org | 117 ++++++++++++----------------- basic-data-type/slides.tex | 182 +++++++++++++++++++-------------------------- 3 files changed, 145 insertions(+), 243 deletions(-) diff --git a/basic-data-type/script.rst b/basic-data-type/script.rst index 3dc92b4..22d4f3a 100644 --- a/basic-data-type/script.rst +++ b/basic-data-type/script.rst @@ -16,8 +16,6 @@ External Reviewer : Checklist OK? : [2010-10-05] -.. #[Puneeth: Fill in pre-requisites.] - Hello friends and welcome to the tutorial on Basic Data types and operators in Python. @@ -40,13 +38,6 @@ In this tutorial, we shall look at * string * tuple -.. #[Puneeth: Use double colon only for code blocks.] -.. #[Puneeth: include more details in the outline.] - -with a little hands-on on how they can be applied to the different data types. - - - First we will explore python data structures in the domain of numbers. There are three built-in data types in python to represent numbers. @@ -58,12 +49,6 @@ These are: * float * complex -.. #[Puneeth: Changed to int, float and complex.] - -.. #[Puneeth: Loss of consistency. You talk of built-in data types, but -.. then you were calling them integers, floats and complex. Clean up -.. required.] - Lets first talk about int. :: a = 13 @@ -78,17 +63,14 @@ If we now see :: type(a) -This means that a is a type of int. Being an int data type in python -means that there are various functions that this variable has to manipulate -in different ways. You can explore these by doing, +This means that a is a type of int. There are lot of functions associated +with the int datatype, to manipulate it in different ways. These can be +explored by doing, :: a. -.. #[Puneeth: Why are we suddenly talking of limits? -.. Something like this would be better. -.. int data-type can hold integers of any size. for example - ] - *int* datatype can hold integers of any size lets see this by an example. +:: b = 99999999999999999999 b @@ -97,11 +79,6 @@ As you can see even when we put a value of 9 repeated 20 times python did not complain. This is because python's int data-type can hold integers of any size. -.. #[Puneeth: again, the clean-up that I talked of above. Decide if you are -.. talking about the different type of numbers and the datatypes that are -.. used to represent them or if you are talking of the data-types and what -.. kind of numbers they represent. I think you should choose the former.] - Let us now look at the float data-type. Decimal numbers in python are represented by the float data-type :: @@ -109,10 +86,10 @@ Decimal numbers in python are represented by the float data-type :: p = 3.141592 p -If you notice the value of output of p isn't exactly equal to p. This is -because computer saves floating point values in a specific format. There is -always an aproximationation. This is why we should never rely on equality -of floating point numbers in a program. +If you notice the value of output of ``p`` isn't exactly equal to ``p``. +This is because computer saves floating point values in a specific format. +There is always an approximation. This is why we should never rely on +equality of floating point numbers in a program. The last data type in the list is complex number :: @@ -120,7 +97,7 @@ The last data type in the list is complex number :: as simple as that so essentialy its just a combination of two floats the imaginary part being defined by j notation instead of i. Complex numbers -have a lot of functions specific to them. Lets check these :: +have a lot of functions specific to them. Let us look at these :: c. @@ -174,10 +151,6 @@ You can apply different Boolean operations on t now for example :: The results are self explanatory. -.. #[Puneeth: Why does booleans bring us to precedence? I don't see the -.. connection. Am I missing something?] - - What if you want to apply one operator before another. Well you can use parenthesis for precedence. @@ -189,8 +162,6 @@ Lets write some piece of code to check this out.:: c=True -.. #[Puneeth: Consistency. In[]: is not present at other places.] - To check how precedence changes with parenthesis, we will try two expressions and their evaluation. @@ -210,14 +181,12 @@ gives the value False. Let's now look at some operators available in Python to manipulate these data types. -.. #[Puneeth: A mention of other operators would be good? Starting -.. with % and ** is a bit weird.] - Python uses '+' for addition :: 23 + 74 '-' for subtraction :: + 23 - 56 '*' for multiplication :: @@ -264,26 +233,26 @@ is same as :: a=a/23 -Following is an (are) exercise(s) that you must do. +Following is are exercises that you must do. %% %% Using python find sqaure root of 3? + +%% %% Is 3**1/2 and 3**0.5 same + +Please, pause the video here. Do the exercises and then continue. + :: 3**0.5 -%% %% Is 3**1/2 and 3**0.5 same :: No,One gives an int answer and the other float -Please, pause the video here. Do the exercises and then continue. - Lets now discuss sequence data types in Python. Sequence data types are those in which elements are kept in a sequential order and all the elements are accessed using index numbers. -.. #[Puneeth: fix the last sentence - it sounds incomplete] - {{{ slide introducing sequence datatype }}} The sequence datatypes in Python are :: @@ -310,8 +279,6 @@ We can have a list something like :: var_list = [1, 1.2, [1,2]] var_list -.. #[Puneeth: some continuity, when jumping to strings?] - Lets look at another sequence data type, strings type :: @@ -329,12 +296,8 @@ Python strings can actually be defined in three different ways :: l="Let's see how to include a single quote" m='''"Let's see how to include both"''' -.. #[Puneeth: Contain's? That's not a word!] - As you can see, single quotes are used as delimiters usually. -.. #[Puneeth: Thus?] - When a string contains a single quote, double quotes are used as delimiters. When a string quote contains both single and double quotes, triple quotes are used as delimiters. @@ -403,10 +366,8 @@ Get a sorted list :: sorted(num_list) -As a consequence of there order we can access a group of elements -in a sequence,together. This is called slicing and striding. - -.. #[Puneeth: Fix the sentence above. ] +As a consequence of their order, we can access a group of elements in a +sequence, together. This is called slicing and striding. First lets discuss Slicing, @@ -563,8 +524,8 @@ it is change it to 21. Please, pause the video here. Do the exercise(s) and then continue. - -In this tutorial we have discussed +This brings us to the end of the tutorial. In this tutorial we have +discussed 1. Number Datatypes , integer,float and complex 2. Boolean and datatype and operators @@ -574,16 +535,6 @@ In this tutorial we have discussed 6. Finding length , sorting and reversing operations on sequences. 7. Immutability. - - - -.. #[Nishanth]: string to list is fine. But list to string can be left for - string manipulations. Just say it requires some string - manipulations and leave it there. - -.. #[Nishanth]: Where is the summary - There are no exercises in the script - {{{ Show the "sponsored by FOSSEE" slide }}} This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India diff --git a/basic-data-type/slides.org b/basic-data-type/slides.org index 84bee21..b78549f 100644 --- a/basic-data-type/slides.org +++ b/basic-data-type/slides.org @@ -21,47 +21,46 @@ #+TITLE: Plotting Data #+AUTHOR: FOSSEE #+DATE: 2010-09-14 Tue -#+EMAIL: info@fossee.in +#+EMAIL: info@fossee.in #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en -#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t +#+OPTIONS: H:1 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc - +#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate * Outline ** Datatypes in Python - - Numbers - - Boolean - - Sequence -** Operators in Python - - Arithmetic Operators - - Boolean Operators +*** Numbers +*** Boolean +*** Sequence +** Operators in Python +*** Arithmetic Operators +*** Boolean Operators ** Python Sequence Datatypes - - list - - string - - tuple +*** list +*** string +*** tuple * Numbers - - Integers - - Float - - Complex + - int + - float + - complex * Question 1 - Find the absolute value of 3+4j * Solution 1 - - abs(3+4j) - + #+begin_src python + abs(3+4j) + #+end_src python * Question 2 - What is the datatype of number 999999999999999999? Is it not int? * Solution 2 - - - Long - - Large integers numbers are internally stored in python - as Long datatype. + - Long + - Large integers numbers are internally stored in python as Long + datatype. * Boolean @@ -70,16 +69,16 @@ not int? In []: f=False #+end_src -* Question 1 +* Question 3 - Using python find sqaure root of 3? -* Solution 1 +* Solution 3 - 3**0.5 -* Question 2 +* Question 4 - Is 3**1/2 and 3**0.5 same -* Solution 2 +* Solution 4 - No,One gives an int answer and the other float * Sequence Data types @@ -93,71 +92,51 @@ not int? * All are Strings #+begin_src python - k='Single quote' - l="Double quote contain's single quote" - m='''"Contain's both"''' + k = 'Single quote' + l = "Double quote contain's single quote" + m = '''"Contain's both"''' #+end_src * Immutabilty Error #+begin_src python In []: greeting_string[1]='k' - --------------------------------------------------------------------------- - TypeError Traceback (most recent call last) + ------------------------------------------------------- + TypeError Traceback (most recent call last) - /home/amit/st-scripts/basic-data-type/ in () + /home/fossee/ in () TypeError: 'str' object does not support item assignment #+end_src -* Question 1 - - Check if 3 is an element of the list [1,7,5,3,4]. In case -it is change it to 21. +* Question 5 + Check if 3 is an element of the list [1,7,5,3,4]. In case it is +change it to 21. -* Solution 1 +* Solution 5 #+begin_src python l=[1,7,5,3,4] 3 in l l[3]=21 l #+end_src -* Question 2 - - Convert the string "Elizabeth is queen of england" to -"Elizabeth is queen" +* Question 6 + Convert the string ~"Elizabeth is queen of england"~ to ~"Elizabeth is +queen"~ -* Solution 2 +* Solution 6 #+begin_src python - s="Elizabeth is queen of england" - stemp=s.split() + s = "Elizabeth is queen of england" + stemp = s.split() ' '.join(stemp[:3]) #+end_src * Summary - #+begin_src python - a=73 - b=3.14 - c=3+4j - - #+end_src -* Summary Contd. - #+begin_src python - t=True - f=False - t and f - #+end_src -* Summary Contd. - #+begin_src python - l= [2,1,4,3] - s='hello' - tu=(1,2,3,4) - #+end_src -* Summary Contd. - #+begin_src python - tu[-1] - s[1:-1] - #+end_src -* Summary Contd. - #+begin_src python - Sorted(l) - #+end_src + - Number Datatypes -- integer,float and complex + - Boolean and datatype and operators + - Sequence data types -- List, String and Tuple + - Accesing sequence + - Slicing sequences + - Finding length, sorting and reversing operations on sequences + - Immutability * Thank you! #+begin_latex \begin{block}{} diff --git a/basic-data-type/slides.tex b/basic-data-type/slides.tex index 586f169..eeb2885 100644 --- a/basic-data-type/slides.tex +++ b/basic-data-type/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-11-09 Tue 01:27 +% Created 2010-11-09 Tue 14:56 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -41,7 +40,6 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} - \begin{frame} \frametitle{Outline} \label{sec-1} @@ -50,29 +48,36 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \item Datatypes in Python \label{sec-1_1}% \begin{itemize} -\item Numbers -\item Boolean -\item Sequence -\end{itemize} +\item Numbers\\ +\label{sec-1_1_1}% +\item Boolean\\ +\label{sec-1_1_2}% +\item Sequence\\ +\label{sec-1_1_3}% +\end{itemize} % ends low level \item Operators in Python \label{sec-1_2}% \begin{itemize} -\item Arithmetic Operators -\item Boolean Operators -\end{itemize} +\item Arithmetic Operators\\ +\label{sec-1_2_1}% +\item Boolean Operators\\ +\label{sec-1_2_2}% +\end{itemize} % ends low level \item Python Sequence Datatypes \label{sec-1_3}% \begin{itemize} -\item list -\item string -\item tuple -\end{itemize} - +\item list\\ +\label{sec-1_3_1}% +\item string\\ +\label{sec-1_3_2}% +\item tuple\\ +\label{sec-1_3_3}% +\end{itemize} % ends low level \end{itemize} % ends low level \end{frame} \begin{frame} @@ -80,9 +85,9 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \label{sec-2} \begin{itemize} -\item Integers -\item Float -\item Complex +\item int +\item float +\item complex \end{itemize} \end{frame} \begin{frame} @@ -93,12 +98,14 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \item Find the absolute value of 3+4j \end{itemize} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Solution 1} \label{sec-4} - - abs(3+4j) +\lstset{language=Python} +\begin{lstlisting} +abs(3+4j) +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Question 2} @@ -114,25 +121,25 @@ not int? \frametitle{Solution 2} \label{sec-6} - + \begin{itemize} \item Long -\item Large integers numbers are internally stored in python +\item Large integers numbers are internally stored in python as Long + datatype. \end{itemize} - - as Long datatype. \end{frame} \begin{frame}[fragile] \frametitle{Boolean} \label{sec-7} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: t=True In []: f=False -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} -\frametitle{Question 1} +\frametitle{Question 3} \label{sec-8} \begin{itemize} @@ -140,7 +147,7 @@ In []: f=False \end{itemize} \end{frame} \begin{frame} -\frametitle{Solution 1} +\frametitle{Solution 3} \label{sec-9} @@ -149,7 +156,7 @@ In []: f=False \end{itemize} \end{frame} \begin{frame} -\frametitle{Question 2} +\frametitle{Question 4} \label{sec-10} \begin{itemize} @@ -157,7 +164,7 @@ In []: f=False \end{itemize} \end{frame} \begin{frame} -\frametitle{Solution 2} +\frametitle{Solution 4} \label{sec-11} \begin{itemize} @@ -192,117 +199,82 @@ In []: f=False \frametitle{All are Strings} \label{sec-13} -\begin{verbatim} -k='Single quote' -l="Double quote contain's single quote" -m='''"Contain's both"''' -\end{verbatim} +\lstset{language=Python} +\begin{lstlisting} +k = 'Single quote' +l = "Double quote contain's single quote" +m = '''"Contain's both"''' +\end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Immutabilty Error} \label{sec-14} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: greeting_string[1]='k' ---------------------------------------------------------------------------- -TypeError Traceback (most recent call last) +------------------------------------------------------- +TypeError Traceback (most recent call last) -/home/amit/st-scripts/basic-data-type/ in () +/home/fossee/ in () TypeError: 'str' object does not support item assignment -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} -\frametitle{Question 1} +\frametitle{Question 5} \label{sec-15} -\begin{itemize} -\item Check if 3 is an element of the list [1,7,5,3,4]. In case -\end{itemize} - -it is change it to 21. + Check if 3 is an element of the list [1,7,5,3,4]. In case it is +change it to 21. \end{frame} \begin{frame}[fragile] -\frametitle{Solution 1} +\frametitle{Solution 5} \label{sec-16} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} l=[1,7,5,3,4] 3 in l l[3]=21 l -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} -\frametitle{Question 2} +\frametitle{Question 6} \label{sec-17} -\begin{itemize} -\item Convert the string ``Elizabeth is queen of england'' to -\end{itemize} - -``Elizabeth is queen'' + Convert the string \~{}''Elizabeth is queen of england''\~{} to \~{}''Elizabeth is +queen''\~{} \end{frame} \begin{frame}[fragile] -\frametitle{Solution 2} +\frametitle{Solution 6} \label{sec-18} -\begin{verbatim} -s="Elizabeth is queen of england" -stemp=s.split() +\lstset{language=Python} +\begin{lstlisting} +s = "Elizabeth is queen of england" +stemp = s.split() ' '.join(stemp[:3]) -\end{verbatim} +\end{lstlisting} \end{frame} -\begin{frame}[fragile] +\begin{frame} \frametitle{Summary} \label{sec-19} -\begin{verbatim} -a=73 -b=3.14 -c=3+4j -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Summary Contd.} -\label{sec-20} - -\begin{verbatim} -t=True -f=False -t and f -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Summary Contd.} -\label{sec-21} - -\begin{verbatim} -l= [2,1,4,3] -s='hello' -tu=(1,2,3,4) -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Summary Contd.} -\label{sec-22} - -\begin{verbatim} -tu[-1] -s[1:-1] -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Summary Contd.} -\label{sec-23} - -\begin{verbatim} -Sorted(l) -\end{verbatim} +\begin{itemize} +\item Number Datatypes -- integer,float and complex +\item Boolean and datatype and operators +\item Sequence data types -- List, String and Tuple +\item Accesing sequence +\item Slicing sequences +\item Finding length, sorting and reversing operations on sequences +\item Immutability +\end{itemize} \end{frame} \begin{frame} \frametitle{Thank you!} -\label{sec-24} +\label{sec-20} \begin{block}{} \begin{center} -- cgit