embellishing_a_plot/questions.rst
author amit
Tue, 26 Oct 2010 15:44:09 +0530
changeset 349 9ced58c5c3b6
parent 235 80e4016d747a
permissions -rw-r--r--
Added long answer type problems in all scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
235
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     1
Objective Questions
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     2
-------------------
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     3
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     4
 1. Draw a plot of cosine graph between -2pi to 2pi with line thickness 4
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     5
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     6
    Answer::
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     7
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     8
    x = linspace(-2*pi, 2*pi)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     9
    plot(x, cos(x), linewidth=4)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    10
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    11
 2. Draw a plot of the polynomial x^2-5x+6 in the range 0 to 5 in blue dotted
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    12
    line
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    13
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    14
    Answer::
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    15
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    16
    x = linspace(-2*pi, 2*pi)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    17
    plot(x, x**2 - 5*x + 6, 'r.')
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    18
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    19
 3. Which marker is used to get circles
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    20
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    21
    a. '.'
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    22
    #. '^'
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    23
    #. 'o'
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    24
    #. '--'
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    25
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    26
 4. What does the '^' marker produce
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    27
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    28
    Answer: Triangle up marker
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    29
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    30
 5. How do you set the title as x^2-5x+6 in LaTex style formatting
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    31
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    32
    Answer: title("$x^2-5x+6$")
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    33
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    34
6. What happens when the following code is executed::
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    35
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    36
    xlabel("First label")
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    37
    xlabel("Second label")
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    38
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    39
   Answer: The label of x-axis is set to "Second label"
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    40
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    41
 7. Read thorugh the documentation and find out is there a way to modify the
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    42
    alignment of text in the command ``ylabel``
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    43
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    44
   a. Yes
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    45
   #. No
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    46
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    47
   Answer: No
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    48
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    49
 8. How to add the annotation "Maxima" at the point (1, 2)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    50
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    51
   Answer: annotate("Maxima", xy=(1, 2))
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    52
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    53
 9. Is the command ``annotate("max", (1, 2))`` same as ``annotate("max",
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    54
    xy=(1, 2)``
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    55
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    56
    a. True
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    57
    b. False
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    58
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    59
    Answer: True
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    60
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    61
 10. When a new annotation is made at a point, what happens to the old one
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    62
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    63
    a. It is replaced
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    64
    b. It is overwritten
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    65
    c. The new annotation is combined with old one
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    66
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    67
    Answer: It is overwritten
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    68
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    69
 11. What happens when xlim is used without arguments
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    70
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    71
    Answer: It gives the current limits of x-axis
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    72
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    73
 12. What happens when ``ylim(0, 5)`` is used
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    74
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    75
    Answer: It sets the lower and upper limits of y-axis to 0 and 5
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    76
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    77
 13. Draw a cosine plot from 0 to 2*pi with green dots. annotate the origin as
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    78
     "origin" and set x and y labels to "x" and cos(x) and x limits to 0 and
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    79
     2pi and y limits to -1.2 and 1.2
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    80
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    81
    Answer::
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    82
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    83
      x = linspace(0, 2*pi)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    84
      plot(x, cos(x), 'g.')
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    85
      annotate("origin", (0, 0))
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    86
      xlabel("$x$")
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    87
      ylabel("$cos(x)$")
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    88
      xlim(0, 2*pi)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    89
      ylim(-1.2, 1.2)
80e4016d747a Converted the embellishing_a_plot to new template form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    90