CSC111 Homework 1
The TA hours and locations are posted here.
The goal of this assignment is for you to learn how to use emacs, the editor you will be using to write your programs.
This homework is due any time before midnight, on 02/4/10. The programs will be collected automatically at midnight on that date. Make sure you submit your program before the deadline, otherwise it will not be collected, and you will receive a failing grade.
You can submit your files/programs multiple times. Every time you do so, the last version is erased and replaced by the new one.
Problem #1
The text below shows you two columns of text. The column on the left is a short story from Fulghum's book "All I really need to know I learned in Kindergarten." You already had a taste of it in the lab. Now you'll have to straighten out the whole story! The right column contains pointers that will help you correct the text on the left.
- The first thing to do is to get a copy of the file to edit. Get it using "getcopy," as follows:
[111c-xx@beowulf ~]$ getcopy fulghum.long
- Check your directory to make sure that the file is there. To do so, use the ls (ell ess) command as follows:
[111c-bz@beowulf ~]$ ls (the two letters are ell and ess)
- . Once you see the file fulghum.long in your directory, edit it with emacs:
[111c-bz@beowulf ~]$ emacs fulghum.long
- Using the information that is provided to you in the right column below, modify the file. If at some point you really mess up and you want to start over again, you can get a brand new copy of the file by retyping the getcopy command. Don't hesitate to work in the lab during one of our Teaching Assistants weekly hours, so that they can help you getting acquainted with Emacs.
Now |Join the lines together
let |(c-e) (c-k)
me |
tell you about Larry Walters, my hero. Walters is |
is is is is is is is is a truck driver, |
thirty-three years old. He is sitting in his lawn |
chair in his backyard, wishing he could fly. For |
as long as he could remember, he wishing he go up. |
as long as he could remember, he wishing he go up. |< several copies of the
as long as he could remember, he wishing he go up. | same line here. Delete
as long as he could remember, he wishing he go up. | them with c-k
as long as he could remember, he wishing he go up. |
To be able to just rise right up in the air and |
see for a long way. The time, money, education, |
and opportunity to be a pilot were not his. Hang |
gliding was too ~!@#$%^&*()_+ dangerous, and any |< Extra characters here!
good | remove them! (c-d)
place |< Here again, Join lines
for | together
gliding |
was too far away. So he he he he he he he |< "he" repeated too many
spent a lot of summer afternoons sitting in his | times. Use Esc-d
backyard in his ordinary old aluminum lawn |
chair--the kind with the webbing and nails. Just |< Change word "nails"
like the one you've got in your backyard. | and replace by "rivets"
|
THE NEXT CHAPTER IN THIS STORY is carried by the |< delete words and retype
newspapers and television. There's old Larry | them in lower case
Walters up in the air over Los Angeles. Flying at |
last. Really getting UP there. Still sitting in |
his aluminum lawn chair, but it's hooked on to |
forty-five helium-filled surplus weather balloons. | In the lines below, find
Larry has a parachute on, a CB radio, a six-pack | every occurrence of ??
of beer, some peanut butter and jelly sandwiches, | and replace it with the
and a BB gun to pop some of the balloons to come | word indicated in the
down. And instead of being just a couple of | right column.
hundred feet over his neighborhood, he shot up | Use c-s to search for
eleven thousand feet, right through the approach | ??
corridor to the ?? International |> ?? --> Los Angeles
Airport |
|
Walters is a ?? man. When asked by the |> ?? --> taciturn
press why he did it, he said: "You can't just sit |
there." When asked if he was scared, he answered: |
"Wonderfully so." When asked if he would do it |
??, he said: "nope." And asked if he was glad |> ?? --> again
that he did it, he grinned from ear to ear and |
said: "Oh, yes." The human race sits in its ??. |> ?? --> chair
On the once hand is the message that says there's |
nothing left to do. And the Larry Walterses of |
the earth are busy tying balloons to their chairs, |
directed by dreams and imagination to do their |
thing. The human race sits in its ??. On the |> ?? --> chair
one hand is the message that the human situation |
is hopeless. And the Larry Walterses of the earth |
soar upward knowing anything is possible, sending |
THIS WORDS SHOULD BE DELETED back the message from |> Delete 5 words
eleven thousand feet: "I did it, I really did it. |
I'm FLYING!" |
|
It's the spirit here thAt counts. The time mAy be |> In this last chapter
long, the vehicle mAy be strAnge or unexpected. | all lower case letters
But if the dreAm is held close to the heArt, And | "a" have been replaced by
imAginAtion is Applied to whAt there is close At | uppercase letters "A".
hAnd, everything is still possible. But wAit! | To change all of them at
Some cynic from the edge of the crowd insists thAt | once, position the
humAn beings still cAn't reAlly fly. Not like | cursor on the first line
birds, AnywAy. True. But somewhere in some | and type the command:
little gArAge, some mAniAc with A gleAm in his eye |
is scArfing vitAmins And minerAl supplements, And | ESC-X replace-string
prActicing flApping his Arms fAster And fAster. | (enter) A (enter) a
|
Robert Fulghum. |
- When you are finished, leave the editor (c-x c-c), and you are done! Make sure you have reconstructed the text to what its original form should be. You will be given a tool during the week to compare your file to the original. More details to come in class!
- Note: You can test your file against the solution file by typing the following command at the prompt:
[111c-xx@beowulf ~]$ testhw1 fulghum.long
- The checking program will compare your file against the original story, and will show you where they are different. Here is an example:
[...]
THE next chapter in this story is carried by the | The next chapter in this story is carried by the
newspapers and television. There's old Larry Walters up in | newspapers and television. There's old Larry
the air over Los Angeles. Flying at | Walters up in the air over Los Angeles. Flying at
last. Really getting UP there. Still sitting in last. Really getting UP there. Still sitting in
his aluminum lawn chair, but it's hooked on to his aluminum lawn chair, but it's hooked on to
forty-five helium-filled surplus weather balloons. forty-five helium-filled surplus weather balloons.
[...]
- The output of the program testhw1 compares your file (on the left) to the original text (on the right), and flags the line or lines that differ with a |-sign (vertical bar) or a >-sign (greater than). This should help you figure out where you have more editing to do.
- Once the output does not contain any vertical-bar or greater-than signs, you are done.
- Submit your file for it to be graded as follows:
submit hw1 fulghum.long
- This will create a copy of your file in your instructor's computer account. You can submit a file several times, as long as it is done before the deadline!
Problem #2
- Write a python program called hw1.py that will ask the user for several pieces of information, including the user's name first name, the user's last name, the user's salary, and the user's deductions. The program then outputs a small report indicating what the user will have to pay in taxes for the year.
- The formula you have to use is the following one:
Amount of federal taxes = ( salary - deductions ) x 28% Amount of state taxes = ( salary - deductions - 1000 ) x 5%
- Here is an example of how your program should behave for a user named "Alex Andra" who earned $50,000 in 2009, and has $6,000 in deductions. The user input is in bold face.
[111c-xx@beowulf ~]$ python hw1.py This program will compute your taxes for 2009 Please enter your first name: Alex Please enter your last name: Andra Enter your salary for 2009: 50000 Enter your deductions: 6000 Dear Alex Andra : your federal taxes for 2009 are $ 12320.0 your state taxes for 2009 are $ 2150.0 you will have to pay a total of $ 14470.0 in taxes.
Recommendations
- Do not worry about the format of your program output too much. It is more important for the program to output the correct information than for its output to match exactly what is shown above.
- Make sure, however, that your program asks the user for 4 separate pieces of information, and they should be the first name, last name, total income, and deductions. This is important as your program will be tested by another program which will feed blindly two names and two numbers to all the submitted programs to check if they compute the correct information.
- Make sure your program is well documented, that you have included your name and account number in the header, and that you have added comments in various places of the code as we will discuss in future lectures.
- When you are satisfied that your program is finished and ready to be submitted, enter the following command at the Unix prompt:
[111c-xx@beowulf ~]$ submit hw1 hw1.py
A Note on Grading
- A fully edited fulghum text that does not generate any |, >, or < signs when tested with the testhw1 utility will be worth an A. Every couple of errors will bring this down by a third of a point (from A to A-, from A- to B+, etc).
- A python program that outputs the correct information and is well documented will be worth an A. Poor or lacking documentation will take a whole point off (from A to B). You will be given examples of good documentation in future lectures.
- Incorrect output will take from 1/3 point to a full point off.
- A program that crashes (stops working before terminating normally) will take 2 points off.
- Unsubmitted files will count for a failing grade (E).
- The grades obtained for the two parts of this assignment will be averaged out with a 50/50 ratio.