CS8, 10F, H02, due Fri Lab 10.01—Rest of Miller/Ranum Ch1 (thru p. 42).—Total points: ?

Available online as http://www.cs.ucsb.edu/~pconrad/cs8/10F/homework/H02—printable PDF

Name: (4 pts)   Umail Address: (4 pts)   @umail.ucsb.edu
Lab Section (2 pts)—circle one:  9am   10am   11am   noon   unknown   crashing 
You may collaborate with at most ONE other person on this homework assignment. If you do, please enter his/her name here:  
  (He/she should also enter your name on her/his assignment.)

(Note: For now, circle the lab section you are registered for on GOLD. If you need to request attendance at a different lab section because of an ACTUAL SCHEDULE CONFLICT, please email pconrad@cs.ucsb.edu with details)


This assignment is due in Lab on Friday, 10.01.
It may ONLY be submitted in Lab, in ESB1003 (Cooper Lab) on Friday.
You must come IN PERSON to turn it in during your assigned Lab section.

Late Policy: No email submission allowed—and don't "slip it under my door". If you need to make it up, you must do so during office hours, or make an appointment to see me, and you must request this appointment within 48 hours of when the assignment was originally due.

Personal Day/Sick Day policy: Everyone is permitted one "personal day/sick day" when you get to make up a missed homework assignment for free during office hours or via appointment. After that, you may not make up the homework assignment—you can only earn back the points through extra credit opportunities.

(For more details, see the syllabus and the homework policy)


Reading: Read the syllabus for the course, and then read Chapter 1, through page 42. Then, answer the following questions. Be sure to check both sides.

  1.  x x x x x x 
    o o o
    o o o

    Concrete instances of the abstraction "six"

     6   0110  Mayan Number six
    ۶  ٦  VI   ו

    Various symbols for the abstraction six
    top: decimal, binary, Chinese, Mayan
    bottom: Persian, Arabic, Roman. Hebrew (vav)

    (10 pts) The syllabus describes what an abstraction is. An index (as in the index of a book) is provided as an example of an abstraction, because although every index for every book is different, they all have common features—if you know how to use one index, you know how to use every index. They all are organized first by topics (in alphabetical order), and for each topic there is a list of relevant pages (in numerical order.) They are often organized in multiple columns, and sometimes there are sub-topics under more general topics.

    In lecture we also talked about numbers as an abstraction. For example the number six is an abstraction of situations such as the ones shown in the top box at right—six x's, six o's, or six dots on the face of a die—and that abstraction can be represented using various symbols (shown in the second box at right.)

    The idea of an abstraction is so fundamental—and so familiar—that it is difficult to define it in simple language, but here is one attempt:

    • a general concept that reveals the common properties of instances that
      are relevant for a particular purpose.

    Review this description of abstractions and then provide your own example of an abstraction that you use in daily life, and describe why that is an abstraction.








Please turn over for more...

...continued from other side

Review pages 29-42 (the remainder of Chapter 1), then answer these questions

  1. (15 pts) Write a function definition in Python. The name of the function is drawRectangle.

    The function takes three parameters. The first is called t, and will stand for the name of a turtle. The second is width, and will stand for how wide the rectangle is. The third is called height, and will stand for how tall the rectangle is.

    Assume that the turtle starts by facing "east", at the lower left corner of the rectangle. That is, the turtle will first draw the "bottom" line of the rectangle across, then draw "up" the right side, then back across the "top" of the rectangle, and finally, back down the left side.

    (5 points for getting the first line of this function definition correct... the other ten points are for the rest of the function. If you aren't sure how to write the rest of the function, at least try to get the first line.)














  1. (5 pts) Read about the range statement on pages 33 and 34, and review what we did with print(i) in lecture on Wednesday. For example, we showed that:

    For example, we showed that this code: Results in this output:
    for i in range(3):
       print (i)
    0
    1
    2

    With that in mind, answer this question:

    What two lines of python will result in the the sequences of numbers 3,6,9,12, etc. up to 30, being printed, one per line? (with no commas between them?)



  1. Continuing our discussion of the range statement from p. 33 and 34:

    1. (5 pts)Given what you learned in the answer to the previous question, what is the Python code to print the sequence 20,18,16,...,2

      (i.e. even numbers going down by 2 each time, ending with 2, one per line, with no commas between them?)









    2. (5 pts) (For this one, you may need to experiment with the actual Python prompt to discover the answer.)
      What will be printed by:

      for i in range(5,1,-1):
          print(i)









End of H02