Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- Question 1
- 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")?
- Your Answer Score Explanation
- + 10.00
- Total 10.00 / 10.00
- Question 2
- What does the draw handler parameter represent?
- If you've forgotten, refer to the documentation.
- Your Answer Score Explanation
- The canvas 10.00
- Total 10.00 / 10.00
- Question 3
- What happens if you draw text outside the canvas coordinates?
- Try it in CodeSkulptor.
- Your Answer Score Explanation
- 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
- Total 10.00 / 10.00
- Question 4
- 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?
- Try the code in CodeSkulptor.
- Your Answer Score Explanation
- canvas.draw_line((0, 0), (200, 300), 10, "Green") 8.00
- canvas.draw_line((300, 0), (0, 200), 10, "Green") 1.00
- canvas.draw_line((200, 0), (0, 300), 10, "Green") 1.00
- Total 10.00 / 10.00
- Question 5
- Consider the following function definition.
- def date(month, day):
- """Given numbers month and day, returns a string of the form '2/12', with the month followed by the day."""
- return month + "/" + day
- print date(2, 12)
- This definition leads to an error. To fix it, what Python expression should replace the question marks below?
- def date(month, day):
- """Given numbers month and day, returns a string of the form '2/12', with the month followed by the day."""
- return ???
- print date(2, 12)
- Your Answer Score Explanation
- str(month) + "/" + str(day) 10.00
- Total 10.00 / 10.00
- Question 6
- How many instances of the letter "l" are there in the following:
- 1lll1l1l1l1ll1l111ll1l1ll1l1ll1ll111ll1ll1ll1l1ll1ll1ll1ll1lll1l1l1l1l1l1l1l1l1l1l1l1ll1lll1l111ll1l1l1l1l1
- 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.
- Answer for Question 6
- You entered:
- Your Answer Score Explanation
- 60 10.00
- Total 10.00 / 10.00
- Question 7
- Where should your draw_text, draw_line, and similar drawing calls be?
- Your Answer Score Explanation
- In a draw handler, or a helper function called from it 10.00
- Total 10.00 / 10.00
- Question 8
- Which of the following function calls are valid?
- Read the documentation for these functions, and also try the code in CodeSkulptor.
- Your Answer Score Explanation
- float("5 five") 1.00
- float("5") 4.00
- float("5.4") 4.00
- int("five") 1.00
- Total 10.00 / 10.00
- Question 9
- Turn the following description into a CodeSkulptor program, and run it.
- Create a 300-by-300 canvas.
- Draw two circles with radius 20 and white lines of width 10. One is centered at (90,200) and one at (210,200).
- Draw a red line of width 40 from (50,180) to (250,180).
- Draw two red lines of width 5 from (55,170) to (90,120) and from (90,120) to (130,120).
- Draw a red line of width 140 from (180,108) to (180,160).
- The resulting picture is a simple diagram of what?
- Your Answer Score Explanation
- A truck or lorry 10.00
- Total 10.00 / 10.00
- Question 10
- The following is a diagram of an archery target.
- 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?
- Your Answer Score Explanation
- Largest first 10.00
- Correct. Whatever you draw last appears to be on top.
- Total 10.00 / 10.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement