General Details

Due Date: September 14, 2017 [2017-09-14, Thursday of week 03]

The following guidelines are expected for all homework submissions:

Reading, Video, Web Links, and Social Issues

You must read chapters one and two of your textbook. Pay attention to the examples, some of which we will work (or will have worked) in class. Don't be afraid to try them out for yourself!

Check out the following web links for some interesting information. You don't have to write anything for this section, just read, watch, listen, and (above all) THINK. Be ready to talk about your thoughts in class.

Problems From Chapter 1

  • Ch 1, #13: Browse the ACM TechNews at http://technews.acm.org/. Read not only a handful of articles from the current week but also peruse the archives (found at http://technews.acm.org/archives.cfm). Make a list of 10 to 20 interesting headlines that highlight the breadth of computing applications in the everyday world.
  • Ch 1, #16: The answer to the question, Which was the first mechanical computer? depends on a person's definition of a mechanical computing device, but there is a general agreement on which was the first computer that was both general purpose and electronic. What was it called? What was it designed to do? Who were its first programmers?
  • Ch 1, #19: Which franchise has generated more revenue — the Star Wars movie franchise, or the Madden NFL video game franchise? Which has generated more profit? Consider both raw sales numbers as well as revenue from derivative profits. As absolute figures may be hard to come by, be sure to qualify any estimates. Cite the sources used in your research.
  • Problems From Chapter 2

  • Ch 2, #10: Run this script in the JavaScript runner, and describe what happens:
    document.getElementById('scriptArea').style.backgroundColor="yellow"
  • Ch 2, #11: Run this script in the JavaScript runner, and describe what happens:
    document.getElementById('footer').innerHTML="blue"
  • Ch 2, #13: Run the following program a few times in the script runner (copy and paste the code). What does the script do?
          var number = Math.floor( Math.random() * 100 ) + 1;
          for( var i = 1; i <= 10; i++ ) {
             var guess = prompt( "Enter guess #" + i + " (1..100)" );
             if( guess < number ) {
                alert( "Too small" );
             } else if( guess > number ) {
                alert( "Too big." );
             } else {
                alert( "Got it!" );
             }
             if( i === 10 ) {
                alert( "That's enough guessing" );
             }
          }
                    
  • Ch 2, #15: Modify the die-rolling application from Section 2.2.4 so that it rolls two dice instead of just one.
  • Ch 2, #18: Draw a structure diagram (such as the one in Figure 2.7) for the temperature conversion HTML document discussed in Section 2.2.4.
  • Ch 2, #20: Modify the temperature conversion document and script from this chapter so that it converts between kilograms and pounds.
  • Ch 2, #26: Run the following script in a freshly-opened runner or shell:
    alert( location );
    Why do you think something was alerted, even though you did not define the variable location?
  • Python Programming Problems

    Windows version: Download and install Python from this location. Be sure you are installing Python version 3.6.2, and install everything. When installation is completed, start the Python command line from the START button. You will see a command window open with some text about the version followed by the Python prompt of three greater-than signs [>>>]. This is the point at which you type in the code that follows.

    NOTES: DO NOT COPY AND PASTE THE CODE! Type the code in by hand. You DO NOT need to type the triple dots at the start of the lines – python will output those for you to indicate you are continuing the same block. For example, type def fib(n): and press the enter key. You will see the triple dot prompt appear on the next line. Leave some space and type the a, b = 0, 1 line, then press the enter key. You'll see the triple dots again on the next line. Keep doing this until you get to the end. On the last line where it says [note: just press… DO NOT enter the note text, simply press the enter key. This will end the function definition. Finally, type the line fib(1000) to run your function program. Here is the code:

          >>> def fib(n):
          ...     a, b = 0, 1
          ...     while a < n:
          ...         print(a, end=' ')
          ...         a, b = b, a+b
          ...     print()
          ...     [note: just press the enter key here]
          >>> fib(1000)
             

    MAC version: Download and install Python from this location. Be sure you are installing Python version 3.6.2, and install everything. When installation is completed, open the applications window and start the IDLE Python GUI program. Select File -> New file from the menu. You will see a second window open into which you can type the program text. When you have typed it according to the following paragrah, select Run -> Run module to run your program. The window will change back to the IDLE GUI, and you should see the output of your program appear. NOTE: you will likely be asked to save your program before running it. This is normal.

    NOTES: DO NOT COPY AND PASTE THE CODE! Type the code in by hand.

    MAC version 2: Use the Python version that is already installed, which comes with the Mac OS. Start a terminal window from the Applications -> Utilities folder in the finder, then type python into the terminal window. You will see the Python prompt of three greater-than signs [>>>]. This is the point at which you type in the code that follows.

    Be CAREFUL to maintain proper indentation — Python is sensitive to it! Here's the code:

          >>> def fib(n):
                  a, b = 0, 1
                  while a < n:
                      print(a, end=' ')
                      a, b = b, a+b
                  print()
          >>> fib(1000)
             
    all versions:

    If everything goes right, you should see the set of Fibonacci numbers for all values less than 1000. In other words, you should see: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

    Now start the idle Python Graphical User Interface (GUI) program. Create a new editor window by selecting File->New File, and enter the following program into the window (Cut and paste). Save the file using the File->Save As menu selection, then select the Run->Run Module option. Describe what happens. Here is the code:

          numbers = [2, 4, 6, 8]
          product = 1
          for number in numbers :
             product = product * number
             print( 'The product is:', product )
             

    If everything goes right, you should see the Python GUI window respond with a RESTART message, followed by four lines of text which contain the product of 1*2, 1*2*4, 1*2*4*6, and 1*2*4*6*8; the results should be 2, 8, 48, and 384.

    You have now installed Python, and can use it for the rest of the exercises that will occur during this semester (and beyond!). Feel free to experiment with some of the problems in the book that you have been given on line.