Advertisement
Guest User

3a

a guest
Oct 31st, 2012
3,820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. You have submitted this quiz on Wed 31 Oct 2012 2:52:31 AM PDT. You achieved a score of 100.00 out of 100.00.
  2. Question 1
  3. What Python operation takes two strings (e.g., "sun" and "rise") and forms the combination of these two strings, one followed by the other (e.g., "sunrise")?
  4.  
  5. Your Answer Score Explanation
  6. + 10.00
  7. Total 10.00 / 10.00
  8. Question 2
  9. What does the draw handler parameter represent?
  10.  
  11. If you've forgotten, refer to the documentation.
  12.  
  13. Your Answer Score Explanation
  14. The canvas 10.00
  15. Total 10.00 / 10.00
  16. Question 3
  17. What happens if you draw text outside the canvas coordinates?
  18.  
  19. Try it in CodeSkulptor.
  20.  
  21. Your Answer Score Explanation
  22. Some or none of the text is shown. Conceptually, the text is drawn at whatever coordinates are given, but only whatever text fits within the canvas coordinates is shown. 10.00
  23. Total 10.00 / 10.00
  24. Question 4
  25. Assume we have a canvas that is 200 pixels wide and 300 pixels high. We want to draw a green line between the upper left corner to the lower right corner. Which of the following calls will accomplish this?
  26.  
  27. Try the code in CodeSkulptor.
  28.  
  29. Your Answer Score Explanation
  30. canvas.draw_line((0, 0), (200, 300), 10, "Green") 8.00
  31. canvas.draw_line((300, 0), (0, 200), 10, "Green") 1.00
  32. canvas.draw_line((200, 0), (0, 300), 10, "Green") 1.00
  33. Total 10.00 / 10.00
  34. Question 5
  35. Consider the following function definition.
  36.  
  37. def date(month, day):
  38. """Given numbers month and day, returns a string of the form '2/12', with the month followed by the day."""
  39. return month + "/" + day
  40.  
  41. print date(2, 12)
  42. This definition leads to an error. To fix it, what Python expression should replace the question marks below?
  43.  
  44. def date(month, day):
  45. """Given numbers month and day, returns a string of the form '2/12', with the month followed by the day."""
  46. return ???
  47.  
  48. print date(2, 12)
  49. Your Answer Score Explanation
  50. str(month) + "/" + str(day) 10.00
  51. Total 10.00 / 10.00
  52. Question 6
  53. How many instances of the letter "l" are there in the following:
  54.  
  55. 1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1
  56. Although it might be hard to tell, that string contains ones (1) and lower-case L's (l). Create a small CodeSkulptor program, and use copy-and-paste to put this string in your code. Your program should only need one function or method call.
  57.  
  58. Answer for Question 6
  59. You entered:
  60.  
  61. Your Answer Score Explanation
  62. 60 10.00
  63. Total 10.00 / 10.00
  64. Question 7
  65. Where should your draw_text, draw_line, and similar drawing calls be?
  66.  
  67. Your Answer Score Explanation
  68. In a draw handler, or a helper function called from it 10.00
  69. Total 10.00 / 10.00
  70. Question 8
  71. Which of the following function calls are valid?
  72.  
  73. Read the documentation for these functions, and also try the code in CodeSkulptor.
  74.  
  75. Your Answer Score Explanation
  76. float("5 five") 1.00
  77. float("5") 4.00
  78. float("5.4") 4.00
  79. int("five") 1.00
  80. Total 10.00 / 10.00
  81. Question 9
  82. Turn the following description into a CodeSkulptor program, and run it.
  83.  
  84. Create a 300-by-300 canvas.
  85. Draw two circles with radius 20 and white lines of width 10. One is centered at (90,200) and one at (210,200).
  86. Draw a red line of width 40 from (50,180) to (250,180).
  87. Draw two red lines of width 5 from (55,170) to (90,120) and from (90,120) to (130,120).
  88. Draw a red line of width 140 from (180,108) to (180,160).
  89. The resulting picture is a simple diagram of what?
  90.  
  91. Your Answer Score Explanation
  92. A truck or lorry 10.00
  93. Total 10.00 / 10.00
  94. Question 10
  95. The following is a diagram of an archery target.
  96.  
  97.  
  98. To draw this in CodeSkulptor, we can put a small yellow circle with a black border on top of a slightly bigger yellow circle with a black border, … on top of a big white circle with a black border. In what order should your code draw these circles?
  99.  
  100. Your Answer Score Explanation
  101. Largest first 10.00
  102. Correct. Whatever you draw last appears to be on top.
  103.  
  104. Total 10.00 / 10.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement