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
-
-
Survey [c]
--
Complete the survey of background and interests.
-
Reading
--
Read online text General Introduction and Simple Python Data
submit at least one reading question by 9am before the next class meeting.
-
Getting familiar with Python expressions [c]
entry --
[C] For each of the following Python programs, useidle3
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:-
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.
-
Navigate to find a terminal application. It may be named
Terminal
orXTerm
. Click on it to open up a terminal window. -
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 nameidle3
. A new window should appear like this:
-
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 charactersHello, world
appear on the next line, followed by another>>>
prompt.
-
Type in the characters
s = input("What is your name? ")
. You should see the charactesWhat 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 charactersHi,
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 afterprint("non-negative")
. This is becauseidle3
recognizes that multiple lines are needed for the computer instruction that begins withif
.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, theelse:
line needs to appear at the beginning of the line instead of being lined up with theprint
instructions. To locate theelse:
at the beginning of the line, enter a backspace/delete character just before you enter those characterselse:
. -
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:
-
-
loop --
[C] Table of square roots. Enter the following intoidle3
, to produce a table of square roots.
sprigs --
[C] Computer art. Enter the following long program intoidle3
, to produce a drawing on the screen.Note: This is a lot of careful typing to do, but it has a purpose: to get you used to typing Python3 programs. Every mistake teaches you something that Python3 is picky about, and figuring out how to recover from and/or avoid those mistakes now will make our work easier in the future. Thus, type these expressions in rather than simply cutting and pasting them, to get the most out of the experience.
-
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.
Pictures
folder. -
- 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.
--
To submit your work from this part:
-
Google translate [c]
--
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?--
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?
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.
-