>>    




Homework Assignment

CS 121 (CS1)

In homework assignments, we will use the following abbreviations:

  • -- [H] Do problem by hand only (computer check is optional).

  • -- [HC] Try problem by hand, then check on the computer.

  • -- [C] Work the problem on the computer. Thinking it out ahead of time is encouraged but optional.

When a problem is marked [HC], be as complete and accurate as possible in your handwritten draft---try to anticipate every subtlety.

Homework 1   Due Wednesday, February 12, 2014
  1. Survey [c]


  2. Reading


  3. Getting familiar with Python expressions [c]

    1. entry -- [C] For each of the following Python programs, use idle3 on a Link computer to type in that program, then take a screen shot of the results and submit that screen shot to the graders, using the steps described below:
      1. The "Link" computers are located in RNS 202 and RNS 203. They run Linux, instead of OS/X (Mac) or Windows. You should be able to log in to any of those computers with your St. Olaf username and password.

      2. Navigate to find a terminal application. It may be named Terminal or XTerm. Click on it to open up a terminal window.

      3. The terminal window provides a "command-line" prompt for running programs: you can type in the name of a program, and it will run that program if available.
        Enter the program name idle3 . A new window should appear like this:

      4. The characters >>> are a prompt in idle3 for you to enter Python3 language expressions (this is the programming language we will use in CS 121). Enter the language expressions from one of the problems below.

        Note: If this is the first time you have used idle3, here are a few things to try in order to get familiar with it.

        • Type in the characters print("Hello, world!") , then press the enter/return key. You should see the characters Hello, world appear on the next line, followed by another >>> prompt.

        • Type in the characters s = input("What is your name? ") . You should see the charactes What is your name? printed on the following line -- it's a prompt! -- giving you an opportunity to answer that question.

        • Next, type in the characters print("Hi,", name) , and press enter/return. This should print the characters Hi, and your name on the next line, followed by the >>> prompt

        • Finally, enter this multi-line expression:

              num = int(input("Enter an integer: "))
              if num < 0:
              	print("negative")
              else:
              	print("non-negative")
          
          
          After the first of these lines, you'll be prompted for an integer, and you'll see the >>> prompt again after you enter that integer. But the >>> prompt will not appear immediately after the following lines, until you enter a blank line after print("non-negative"). This is because idle3 recognizes that multiple lines are needed for the computer instruction that begins with if.

          Your output should look something like this:

          Note: Python expects certain indenting for certain kinds of instruction, and idle3 ordinarily provides appropriate indenting you want automatically. However, the else: line needs to appear at the beginning of the line instead of being lined up with the print instructions. To locate the else: at the beginning of the line, enter a backspace/delete character just before you enter those characters else: .

        • If you make a mistake, you may get a red error message, for example,
            
          If you use the arrow keys or mouse to start changing the erroneous lines, idle3 will provide a new copy of those lines for you to continue:
            

      DO THIS:


    2. To submit your work from this part:

      1. Take a screenshot of a relevant portion of your screen, using the PrintScrn key near the top left of the keyboard.

        • Pressing this key will create a screenshot of the entire screen

        • Holding Shift and pressing this key will allow you to use a mouse "drag" to mark out the region for a screenshot.

        Either kind of screen shot (entire screen or partial) will be fine. The resulting image file will be stored in your Pictures folder.
      2. Email your screen shot to cs1b-graders@stolaf.edu as an attachment. Note: If possible, please email your response to this part together with your response to part D, below.
  4. Google translate [c]

    1. -- Google translate is a "web service" that uses computation on a given text in one language to produce a probable translation of that text into another language.

      The translation computation is based on human translations of billions of words in each language, starting with the official publications of the United Nations, all of which are human translated into all six official UN languages. Those large bodies of text in each language are called corpora (singular is corpus). Statistical computations (a type of machine learning) on the corpora are used to produce software that can produce a probable translation. Errors in translation could arise from a number of causes. For example, when the system doesn't have specific software for a direct translation from language X to language Y, the English language may be used as an intermediary (translate from X into English, then translate from English into Y). This could lead to errors in cases where English is more ambiguous than the languages X and Y. For instance, the same word you is used in English for both formal and informal relationships to a speaker, but French uses different words (vous and tu) for those relationships, as does Russian (вы and ты), so translating from French to Russian through English would lose some of the meaning of the words.

      DO THIS: Use Google translate to translate about 100 words from English another language you are familiar with. Can you detect any flaws in the translation?

    2. -- Checking a translation. Try translating the results of the previous problem back into English, using Google translate. For example, if you previously translated from English into Spanish, then translate that Spanish text back into English. Does the result of double translation match the original English?

    3. To submit your work from this part:

      Submit two screen shots, one for each problem, that show your two google translations. (See above for instructions for making a screenshot.) Then email the screenshots to cs1b-graders@stolaf.edu as attachments. Include any comments or observations about the quality of the translations in the body of your email.