Merged heads, again.
--- a/plotting_using_sage/questions.rst Sun Oct 10 13:44:51 2010 +0530
+++ b/plotting_using_sage/questions.rst Sun Oct 10 13:46:09 2010 +0530
@@ -1,90 +1,70 @@
Objective Questions
-------------------
- 1. If ``a = [1, 1, 2, 3, 3, 5, 5, 8]``. What is set(a)
-
- a. set([1, 1, 2, 3, 3, 5, 5, 8])
- #. set([1, 2, 3, 5, 8])
- #. set([1, 2, 3, 3, 5, 5])
- #. Error
+ 1. Plot the curve ``sin(x) - cos(x)`` in the range (0, 2pi)
- Answer: set([1, 2, 3, 5, 8])
-
- 2. ``a = set([1, 3, 5])``. How do you find the length of a?
-
- Answer: len(a)
-
- 3. ``a = set([1, 3, 5])``. What does a[2] produce?
+ Answer::
- a. 1
- #. 3
- #. 5
- #. Error
-
- Answer: Error
-
- 4. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd | squares``?
+ x = var('x')
+ plot(sin(x) - cos(x), (x, 0, 2*pi))
- Answer: set([1, 3, 4, 5, 7, 9, 16])
-
- 5. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd - squares``?
+ 2. plot ``sin(3x)`` and ``cos(x/3)`` and show them in same figure
- Answer: set([3, 5, 7])
-
- 6. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd ^ squares``?
+ Answer::
- Answer: set([3, 4, 5, 7, 16])
-
- 7. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- does ``odd * squares`` give?
+ x = var('x')
+ p1 = plot(sin(3*x), (x, 0, 2*pi))
+ p2 = plot(cos(x/3), (x, 0, 2*pi))
+ show(p1+p2)
- a. set([1, 12, 45, 112, 9])
- #. set([1, 3, 4, 5, 7, 9, 16])
- #. set([])
- #. Error
-
- Answer: Error
-
- 8. ``a = set([1, 2, 3, 4])`` and ``b = set([5, 6, 7, 8])``. What is ``a + b``
+ 3. plot ``cos(x)`` vs ``sin(x)^15`` in the range (-2pi, 2pi)
- a. set([1, 2, 3, 4, 5, 6, 7, 8])
- #. set([6, 8, 10, 12])
- #. set([5, 12, 21, 32])
- #. Error
-
- 9. ``a`` is a set. how do you check if if a varaible ``b`` exists in ``a``?
-
- Answer: b in a
-
- 10. ``a`` and ``b`` are two sets. What is ``a ^ b == (a - b) | (b - a)``?
+ Answer::
- a. True
- #. False
-
- Answer: False
-
+ x = var('x')
+ parametric_plot((cos(x), sin(x)^15), (x, -2*pi, 2*pi))
-Larger Questions
-----------------
-
- 1. Given that mat_marks is a list of maths marks of a class. Find out the
- no.of duplicates marks in the list.
+ 4. plot tan curve in the range (-2pi, 2pi) in red colour.
+ [hint: see the documentation]
Answer::
- unique_marks = set(mat_marks)
- no_of_duplicates = len(mat_marks) - len(unique_marks)
+ x = var('x')
+ p1 = plot(tan(x), (x, -2*pi, 2*pi), color=(1, 0, 0))
+ show(p1)
+
+ 5. plot ``e^(1/x^2)`` in the range (0.5, 2.5) and set the y-axis limits to (0,
+ 20)
- 2. Given that mat_marks is a list of maths marks of a class. Find how many
- duplicates of each mark exist.
+ Answer::
+
+ x = var('x')
+ p2 = plot(e^(1/x^2), (x, 0.5, 2.5))
+ show(p2, ymin=0, ymax=20)
+
+ 6. plot the function ``y = 5x + 3`` using dotted line in the range (-2, 2)
+ [hint: read the documentation of the function ``line``]
Answer::
- marks_set = set(mat_marks)
- for mark in marks_set:
- occurences = mat_marks.count(mark)
- print occurences - 1, "duplicates of", mark, "exist"
+ points = [ (i, 5*i+3) for i in srange(-2,2,0.1) ]
+ l1 = line(points, linestyle=":")
+ show(l1)
+
+ 7. plot the function ``z = cos(x) + sin(y)`` for x in the range (0, 2pi) and y
+ in range (-2pi, 2pi)
+
+ Answer::
+ x, y = var('x y')
+ plot3d(cos(x) + sin(y), (x, 0, 2*pi), (y, -2*pi, 2*pi))
+
+ 8. Read the sage documentation and find out which function plots closed surfaces
+
+ a. parametric_plot3d
+ #. plot3d
+ #. implicit_plot3d
+ #. contour_plot
+
+ Answer: implicit_plot3d
+
--- a/using_sage_to_teach/questions.rst Sun Oct 10 13:44:51 2010 +0530
+++ b/using_sage_to_teach/questions.rst Sun Oct 10 13:46:09 2010 +0530
@@ -1,90 +1,36 @@
Objective Questions
-------------------
- 1. If ``a = [1, 1, 2, 3, 3, 5, 5, 8]``. What is set(a)
-
- a. set([1, 1, 2, 3, 3, 5, 5, 8])
- #. set([1, 2, 3, 5, 8])
- #. set([1, 2, 3, 3, 5, 5])
- #. Error
-
- Answer: set([1, 2, 3, 5, 8])
-
- 2. ``a = set([1, 3, 5])``. How do you find the length of a?
-
- Answer: len(a)
-
- 3. ``a = set([1, 3, 5])``. What does a[2] produce?
-
- a. 1
- #. 3
- #. 5
- #. Error
+ 1. which default argument, when used with ``@interact`` gives a slider
+ starting at 0 and ending in 10
- Answer: Error
-
- 4. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd | squares``?
-
- Answer: set([1, 3, 4, 5, 7, 9, 16])
-
- 5. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd - squares``?
+ a. (0..11)
+ #. range(0, 11)
+ #. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ #. (0..10)
- Answer: set([3, 5, 7])
-
- 6. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- is the value of ``odd ^ squares``?
+ Answer: (0..10)
- Answer: set([3, 4, 5, 7, 16])
-
- 7. ``odd = set([1, 3, 5, 7, 9])`` and ``squares = set([1, 4, 9, 16])``. What
- does ``odd * squares`` give?
+ 2. What is the input widget resulted by using ``n = [2, 4, 5, 9]`` in the
+ default arguments along with ``@interact``
- a. set([1, 12, 45, 112, 9])
- #. set([1, 3, 4, 5, 7, 9, 16])
- #. set([])
- #. Error
-
- Answer: Error
-
- 8. ``a = set([1, 2, 3, 4])`` and ``b = set([5, 6, 7, 8])``. What is ``a + b``
+ a. input field
+ #. set of buttons
+ #. slider
+ #. None
- a. set([1, 2, 3, 4, 5, 6, 7, 8])
- #. set([6, 8, 10, 12])
- #. set([5, 12, 21, 32])
- #. Error
-
- 9. ``a`` is a set. how do you check if if a varaible ``b`` exists in ``a``?
+ Answer: set of buttons
- Answer: b in a
-
- 10. ``a`` and ``b`` are two sets. What is ``a ^ b == (a - b) | (b - a)``?
-
- a. True
- #. False
+ 3. what is the type of ``n`` in the following function::
- Answer: False
-
-
-Larger Questions
-----------------
-
- 1. Given that mat_marks is a list of maths marks of a class. Find out the
- no.of duplicates marks in the list.
-
- Answer::
+ @interact
+ def f(n=2.5):
+ # do something with n
- unique_marks = set(mat_marks)
- no_of_duplicates = len(mat_marks) - len(unique_marks)
-
- 2. Given that mat_marks is a list of maths marks of a class. Find how many
- duplicates of each mark exist.
+ a. int
+ #. float
+ #. string
+ #. complex
- Answer::
+ Answer: float
- marks_set = set(mat_marks)
- for mark in marks_set:
- occurences = mat_marks.count(mark)
- print occurences - 1, "duplicates of", mark, "exist"
-