diff options
-rw-r--r-- | additional_ipython/script.rst | 5 | ||||
-rw-r--r-- | embellishing_a_plot/quickref.tex | 39 | ||||
-rw-r--r-- | embellishing_a_plot/script.rst | 5 | ||||
-rw-r--r-- | input_output/quickref.tex | 20 | ||||
-rw-r--r-- | input_output/script.rst | 6 | ||||
-rw-r--r-- | lstsq/quickref.tex | 20 | ||||
-rw-r--r-- | lstsq/script.rst | 6 | ||||
-rw-r--r-- | parsing_data/quickref.tex | 20 | ||||
-rw-r--r-- | parsing_data/script.rst | 9 | ||||
-rw-r--r-- | plotting_using_sage/quickref.tex | 35 | ||||
-rw-r--r-- | plotting_using_sage/script.rst | 8 | ||||
-rw-r--r-- | sets/quickref.tex | 28 | ||||
-rw-r--r-- | sets/script.rst | 12 | ||||
-rw-r--r-- | using_sage_to_teach/quickref.tex | 31 | ||||
-rw-r--r-- | using_sage_to_teach/script.rst | 8 | ||||
-rw-r--r-- | writing_python_scripts/quickref.tex | 14 | ||||
-rw-r--r-- | writing_python_scripts/script.rst | 7 |
17 files changed, 171 insertions, 102 deletions
diff --git a/additional_ipython/script.rst b/additional_ipython/script.rst index 581dbf1..bd01a0f 100644 --- a/additional_ipython/script.rst +++ b/additional_ipython/script.rst @@ -1,11 +1,6 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - - .. By the end of this tutorial you will be able to .. #. Retrieve your ipython history diff --git a/embellishing_a_plot/quickref.tex b/embellishing_a_plot/quickref.tex index a0212b3..78459f2 100644 --- a/embellishing_a_plot/quickref.tex +++ b/embellishing_a_plot/quickref.tex @@ -1,11 +1,34 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Plot with a specific color. Ex: RED :\\ +{\ex \lstinline| plot(x, f(x), "r")|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Plot with a specific style. Ex: DASHED :\\ +{\ex \lstinline| plot(x, f(x), "--")|} + +Plot with specific color and style. Ex: RED DASHED :\\ +{\ex \lstinline| plot(x, f(x), "r--")|} + +Plot with a specific line thickness:\\ +{\ex \lstinline| plot(x, f(x), linewidth=3)|} + +Adding title:\\ +{\ex \lstinline| title("Plot of sin(x)")|} + +labelling the axes:\\ +{\ex \lstinline| xlabel("x")|} +{\ex \lstinline| ylabel("f(x)")|} + +Adding annotations:\\ +{\ex \lstinline| annotate("localmax", xy=(1, 2))|} + +Using LaTeX typesetting on any text:\\ +{\ex \lstinline| title("Plot of $sin(x)$")|} + +Getting the axes limits:\\ +{\ex \lstinline| xlim()|} +{\ex \lstinline| ylim()|} + +Setting the axes limits:\\ +{\ex \lstinline| xlim(x_min, x_max)|} +{\ex \lstinline| ylim(y_min, y_max)|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/embellishing_a_plot/script.rst b/embellishing_a_plot/script.rst index 8810157..e964389 100644 --- a/embellishing_a_plot/script.rst +++ b/embellishing_a_plot/script.rst @@ -1,11 +1,6 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - - .. By the end of this tutorial you will be able to .. * Modify the attributes of the plot -- color, line style, linewidth diff --git a/input_output/quickref.tex b/input_output/quickref.tex index a0212b3..43629ca 100644 --- a/input_output/quickref.tex +++ b/input_output/quickref.tex @@ -1,11 +1,15 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Printing a variable:\\ +{\ex \lstinline| print x|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Printing with out a new line:\\ +{\ex \lstinline| print x, |} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Using modifiers while printing:\\ +{\ex \lstinline| print "a is \%d b is \%f"\%(a, b)|} + +Taking input from user:\\ +{\ex \lstinline| x = raw_input()|} + +Display a prompt while taking input:\\ +{\ex \lstinline| x = raw_input("Type a number: ")|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/input_output/script.rst b/input_output/script.rst index e525872..bcac6e9 100644 --- a/input_output/script.rst +++ b/input_output/script.rst @@ -1,17 +1,11 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - - .. #. How to print some value .. #. How to print using modifiers .. #. How to take input from user .. #. How to display a prompt to the user before taking the input - .. Prerequisites .. ------------- diff --git a/lstsq/quickref.tex b/lstsq/quickref.tex index a0212b3..e057739 100644 --- a/lstsq/quickref.tex +++ b/lstsq/quickref.tex @@ -1,11 +1,15 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Creating a matrix with all ones:\\ +{\ex \lstinline| o = ones_like(l)|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Creating the A matrix:\\ +{\ex \lstinline| A = array(l, ones_like(l)).T|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Computing least square:\\ +{\ex \lstinline| result = lstsq(A, tsq)|} + +Obtaining the m and c values:\\ +{\ex \lstinline| m, c = result[0]|} + +Computing the least square fit line:\\ +{\ex \lstinline| lst_line = m * l + c|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/lstsq/script.rst b/lstsq/script.rst index 59f1809..a53524e 100644 --- a/lstsq/script.rst +++ b/lstsq/script.rst @@ -1,11 +1,6 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - - .. Plotting a least square fit line .. Prerequisites @@ -13,6 +8,7 @@ .. 1. Basic Plotting .. 2. Arrays +.. 3. Loading data from files .. Author : Nishanth Amuluru Internal Reviewer : diff --git a/parsing_data/quickref.tex b/parsing_data/quickref.tex index a0212b3..5adaa84 100644 --- a/parsing_data/quickref.tex +++ b/parsing_data/quickref.tex @@ -1,11 +1,15 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Splitting a string on whitespace:\\ +{\ex \lstinline| str_var.split()|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Splitting a string using a delimiter. Ex: ";" :\\ +{\ex \lstinline| str_var.split(";")|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Stripping the whitespace around a string:\\ +{\ex \lstinline| str_var.strip()|} + +Converting a string or float to int:\\ +{\ex \lstinline| int(var_name)|} + +Converting a string or int into float:\\ +{\ex \lstinline| float(var_name)|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/parsing_data/script.rst b/parsing_data/script.rst index 5873132..2a3573c 100644 --- a/parsing_data/script.rst +++ b/parsing_data/script.rst @@ -1,10 +1,11 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - +.. By the end of this tutorial you will be able to + +.. * Split a string using a delimiter +.. * remove the whitespace around the string +.. * convert the variables from one type to other .. Prerequisites .. ------------- diff --git a/plotting_using_sage/quickref.tex b/plotting_using_sage/quickref.tex index a0212b3..44513ac 100644 --- a/plotting_using_sage/quickref.tex +++ b/plotting_using_sage/quickref.tex @@ -1,11 +1,30 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Plot simple 2D functions on a linear range of x:\\ +{\ex \lstinline| plot(f(x), (x, 0, 2*pi)|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Plot 2D plots where x and y are functions of another variable:\\ +{\ex \lstinline| parametric_plot((f_x, f_y), (x, 0, 2*pi), (y, 0, 2*pi))|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Generate a sequence of points with a given seperation:\\ +{\ex \lstinline| points = srange(2.5, 5.5, 0.25)|} + +Plot a line joining a list of pairs of points:\\ +{\ex \lstinline| line(list_pairs)|} + +Show the plots:\\ +{\ex \lstinline| show(plot_name)|} + +Show multiple plots:\\ +{\ex \lstinline| show(p1+p2+p3)|} + +Set x-axis limits:\\ +{\ex \lstinline| show(p1+p2, xmim=0, xmax=2*pi)|} + +Set y-axis limits:\\ +{\ex \lstinline| show(p1+p2, ymim=-1.2, ymax=1.2)|} + +Plot 3D functions:\\ +{\ex \lstinline| plot3d(f(x, y), (x, 0, 2*pi), (y, -1, 1))|} + +Plot 3D functions where x, y, z are functions of another variable:\\ +{\ex \lstinline| parametric_plot3d((f_x, f_y, f_z), (t, 0, 10))|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/plotting_using_sage/script.rst b/plotting_using_sage/script.rst index bcef0dc..04dd06c 100644 --- a/plotting_using_sage/script.rst +++ b/plotting_using_sage/script.rst @@ -1,10 +1,10 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - +.. By the end of this tutorial you will be able to + +.. * Use SAGE for 2D plotting +.. * Use SAGE for 3D plotting .. Prerequisites .. ------------- diff --git a/sets/quickref.tex b/sets/quickref.tex index a0212b3..4e34e59 100644 --- a/sets/quickref.tex +++ b/sets/quickref.tex @@ -1,11 +1,23 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +Creating a set:\\ +{\ex \lstinline| p10 = set([2, 3, 5, 7]) |t} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Creating set from a tuple or list:\\ +{\ex \lstinline| s = set(var_name)|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Operations on sets. Ex: UNION:\\ +{\ex \lstinline| s1 \| s2 |} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} +Other operations available:\\ + +\begin{lstlising} +\item "\&" -- Intersection +\item "-" -- Difference +\item "\^" -- Symmetric Difference +\item "<" -- Subset +\end{lstlisting} + +Checking for containership:\\ +{\ex \lstinline| x in p10|} + +Finding the no.of elements:\\ +{\ex \lstinline| len(p10)|} diff --git a/sets/script.rst b/sets/script.rst index ffc2084..8f9c699 100644 --- a/sets/script.rst +++ b/sets/script.rst @@ -1,11 +1,13 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - Will learn what are tuples and why they are needed - Will learn the various methods of accessing elements in tuples - C - - D - +.. By the end of this tutorial, you will be able to + +.. * Create sets from lists +.. * Perform union, intersection and symmetric difference operations +.. * Check if a set is a subset of other +.. * understand various similarities with lists like length and containership + .. Prerequisites .. ------------- diff --git a/using_sage_to_teach/quickref.tex b/using_sage_to_teach/quickref.tex index a0212b3..68e958a 100644 --- a/using_sage_to_teach/quickref.tex +++ b/using_sage_to_teach/quickref.tex @@ -1,11 +1,26 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +using @interact:\\ +{\ex \lstinline| @interact + def f(a=5,b=[1,2],c=(0..3))|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Default argument for a field input:\\ +{\ex \lstinline| def f(a="hello")|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Default argument for slider:\\ +{\ex \lstinline| def f(a=(1..8))|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} +Default argument for buttons:\\ +{\ex \lstinline| def f(a=[1, 2, 3])|} + +Publish worksheets:\\ +{\ex \lstinline| Use Publish option on top right corner|} + +Re-Publish worksheets:\\ +{\ex \lstinline| Check the auto re-publish option while publishing or click +on publish and click on the re-publish option on the page.|} + +Share the worksheets:\\ +{\ex \lstinline| Click on the share button and enter the usernames|} + +Editing a published worksheet:\\ +{\ex \lstinline| Open the worksheet and click on the edit button on top left +corner|} diff --git a/using_sage_to_teach/script.rst b/using_sage_to_teach/script.rst index 0316a31..094f84f 100644 --- a/using_sage_to_teach/script.rst +++ b/using_sage_to_teach/script.rst @@ -1,10 +1,10 @@ .. Objectives .. ---------- -.. A - Students and teachers from Science and engineering backgrounds - B - - C - - D - +.. By the end of this tutorial you will be able to + +.. * use ``@interact`` feature of SAGE +.. * learn to share, publish and edit SAGE worksheets .. Prerequisites .. ------------- diff --git a/writing_python_scripts/quickref.tex b/writing_python_scripts/quickref.tex index a0212b3..2b24fc9 100644 --- a/writing_python_scripts/quickref.tex +++ b/writing_python_scripts/quickref.tex @@ -1,11 +1,9 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +See where python searches for modules:\\ +{\ex \lstinline| sys.path|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +Include our own path in PYTHONPATH:\\ +{\ex \lstinline| sys.path.append(our_path)|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Run certian code only if executed and not if imported:\\ +{\ex \lstinline| if __name__=="__main__": #do something|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} diff --git a/writing_python_scripts/script.rst b/writing_python_scripts/script.rst index d8268f4..07c91f1 100644 --- a/writing_python_scripts/script.rst +++ b/writing_python_scripts/script.rst @@ -1,8 +1,15 @@ .. Objectives .. ---------- +.. By the end of this tutorial, you will be able to + +.. * Understand what is importing +.. * Write your own Python modules +.. * Understand the ``__name__=="__main__"`` idiom + .. Prerequisites .. ------------- +.. 1. Using Python modules .. Author : Nishanth Amuluru Internal Reviewer : |