# HG changeset patch # User Anoop Jacob Thomas # Date 1286823354 -19800 # Node ID de16a94027f938ca16277858db10f714f0c31103 # Parent d98f554bbec0d4ea065846a292f65d66cea0115d# Parent 56dc2183f1de6a5ea5ee9397d70c76b6e543978d Merged. diff -r d98f554bbec0 -r de16a94027f9 additional_ipython/quickref.tex --- a/additional_ipython/quickref.tex Tue Oct 12 00:25:01 2010 +0530 +++ b/additional_ipython/quickref.tex Tue Oct 12 00:25:54 2010 +0530 @@ -1,11 +1,15 @@ -Creating a tuple:\\ -{\ex \lstinline| t = (1, "hello", 2.5)|} +accessing history:\\ +{\ex \lstinline| \%hist|} -Accessing elements of tuples:\\ -{\ex \lstinline| t[index] Ex: t[2]|} +accessing particular line of history:\\ +{\ex \lstinline| \%hist line_number|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +accessing particular range of history:\\ +{\ex \lstinline| \%hist start_line stop_line|} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} +saving history to a file:\\ +{\ex \lstinline| \%save file_path line_numbers|} + +running a script:\\ +{\ex \lstinline| \%run -i file_path|} + diff -r d98f554bbec0 -r de16a94027f9 using-sage/questions.rst --- a/using-sage/questions.rst Tue Oct 12 00:25:01 2010 +0530 +++ b/using-sage/questions.rst Tue Oct 12 00:25:54 2010 +0530 @@ -1,17 +1,81 @@ Objective --------- -.. A mininum of 8 questions here. +1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends to + ``0`` from the negative side. + + Answer: lim(x/sin(x), x=0, dir="below") + +#. Find the third differential of the function ``exp(sin(x)*cos(x^2))`` + + Answer: diff(exp(sin(x)*cos(x^2), x, 3) + +#. Solve the system of linear equations:: + + x-2y+3z = 7 + 2x+3y-z = 5 + x+2y+4z = 9 + + Answer:: + + A = Matrix([[1, -2, 3], + [2, 3, -1], + [1, 2, 4]]) + + b = vector([7, 5, 9]) + + solve_right(A, b) + +#. How do you get the factorized form of ``x^4 - 4x^2 + x^3 + 2x + 7`` + + Answer:: -1. Question 1 -2. Question 2 -3. Question 3 + factor( x^4 + x^3 - 4*x^2 + 2*x + 7 ) + +#. list all the primes between 2009 and 2900 + + Answer: prime_range(2009, 2901) + +#. Which function is used to check primality + + a. isPrime + #. isprime + #. is_prime + #. prime + + Answer: is_prime + +#. How do you list all the combinations of ``[1, 2, 3, 4]`` + + + Answer:: + + c1 = Combinations([1, 2, 3, 4]) + c1.list() + +#. How do you list all the permutations of ``[1, 3, 2, 3]`` + + Answer:: + + p1 = Permutations([1, 3, 2, 3]) + p2.list() Programming ----------- -.. A minimum of 2 questions here. +1. What is the out put of the following code:: + + c1 = Combinations([1, 2, 3, 4]) + c2 = Combinations([1, 2, 4, 3]) + + l1 = c1.list() + l2 = c2.list() -1. Programming Assignment 1 -2. Programming Assignment 2 + for i in l2: + l1.remove(i) + + print l2 + + Answer: [] +