Homework Assignments - Spring 2010
Introduction to Programming and Algorithm
Design (COP 1000)

Assignments, due dates, and hints are given below, most recent
first. Homework is due by midnight of the date shown. Send
your homework as an email attachment from your FSCJ email account
to sdifranc@fscj.edu.
Include your class, homework number, name, and reference
number in the subject line as described in the
homework guidelines. For example:
COP1000 Hw04 Billy Bob
Thornton Ref #318820
Note: If you are asking for help on an assignment, rather
than turning it in, make sure to include the word "Help" in
the subject line.
Hw08: Lists, Strings, Dictionaries and Files (due 3/17)
Write a program to determine and displays the following:
- (75 Points). The number of words in the U.S. Constitution
(as contained in this text file:
constitu.txt – it includes the text of the Constitution, but
not the signatures nor the Bill of Rights).
- (80 Points). The number of words and the longest word.
- (85 Points). The number of words, the longest word, and the
number of distinct word (regardless of case).
- (90 points). All of the above and the number of times each
of these specific words occur, regardless of case: "war",
"peace", "tax", "church", "vote"
- (95 Points): All of the above plus the most frequently-used
word, and the number of times it is used.
- (100 Points). All of the above and a list of the 20 most
frequently-used words, with the number of times each is used.
To fully succeed in this assignment you will need to use string,
list, dictionary and file methods. Use help to find the best ones
for your approach, and review the example programs.
This is a team project. Here are the teams:
- George A (antogc2) & Eric B (bornee) & Carolyn B (benacv)
- Edin D (dzele) & Anthony F (franal7) & Grant M (millgp)
- Gary Y (young1) & Makhymia S (salamb) & William G (gibbwt)
- Nathan G (gibsn) & Alborz R (rosha1) & James C (chakja)
- Deborah H (hopkdj) & Mpho M (mabamj) & Brandon M (moorba)
- Kristyn M (mierkm) & Naman P (patena2) & Garrett S (stongm)
- Meagan M (morrme) & Brandon H (henrbl1) & Jeffrey H (hestjp)
Turn in the assignment with the filename hw08-xxx.py, where
xxx
is the name of the teammate turning in the assignment. Don't forget
to cc the other teammates.
Hw07: Handling Lists and Strings (due 3/10)
Write a program to construct a userid
from the user's name. The user should be prompted to input his full
name (first middle last) on one line, and the
userid constructed as follows: the first four characters of
the last name + first character of first name + first character of
middle name, all in lowercase (where the + symbol indicated
concatenation). For example, Sarah Jessica Parker's
userid should be
parksj. If the user does not enter a middle name, construct
the userid of the first four characters
of the last name + first character of first name. If the user enters
only a last name, use the first four characters of the the last name
only. If the user enters nothing, display an appropriate message.
Here is a compiled sample:
userid.pyc. Remember that the
split method is very useful for
splitting a string into a list of strings.
Save your source code as hw07-xxx.py
(where xxx are your initials) and submit it via email as described
at the top of this page.
Hw06: eMail Address Validation (due 3/3)
Write a program to accept a string that represents an email
address, and validate it to these specifications:
- The string must contain exactly one '@' symbol
- The '@' symbol cannot be the first or last character in the
string
Display a message indicating that the string is either valid or
not valid as an email address. If it is not valid, provide a brief
explanation of why. See the sample executable
email2.pyc
This is a team assignment. Please review the
guidelines for team assignments. Here
are the teams:
- George A (antogc2) & Carolyn B (benacv)
- Eric B (bornee) & Steven B (broos10)
- James C (chakja) & Edin D (dzele) & Gary Y (young1)
- Susan F (forssm) & Anthony F (franal7)
- William G (gibbwt) & Nathan G (gibsn)
- Brandon H (henrbl1) & Jeffrey H (hestjp)
- Deborah H (hopkdj) & Brandon M (moorba)
- Mpho M (mabamj) & Grant M (millgp)
- Kristyn M (mierkm) & Naman P (patena2)
- Meagan M (morrme) & Alborz R (rosha1)
- Makhymia S (salamb) & Garrett S (stongm)
Turn in the assignment with the filename hw06-xxx.py, where
xxx
is the name of the teammate turning in the assignment. Don't forget
to cc the other teammate(s).
Hw05: Iteration (due 2/24)
Write a program to display the outline of a box using the '*'
character, where the user specifies the width and height of the box,
as in this sample executable: simpbox.pyc
For an extra challenge, you can try these additions (in this
executable: simpbox2.pyc):
- Validate the user input to make sure it falls in the
specified range
- Let the user specify the character to be used for the
outline
- Center a user-supplied message in the box
Save your source code as hw05-xxx.py (where xxx are
your initials) and submit it via email as described at the top of
this page.
Hw04: Cash Register (due 2/10)
Write a program to simulate a cash register as in the sample
program cashreg.pyc.
Try to duplicate its interface and functionality. Improve on it if
you can.
Save and submit your program with the filename hw05-xxx.py,
where xxx are
your initials.
Hw03: Pizza Price (due 2/3)
Write a program to calculate the price of a pizza based on two
user inputs: size (S, M, or L) and number of toppings. Obtain the
inputs and display the result in main;
calculate the price of pizza in a fruitful function, as follows:
- Base price of the pizza is $8.50 for small, $10.50 for
medium, and $12.50 for large
- The first topping is free; the second and subsequent topping
is an addition $0.50 each
- Sales tax is an additional 7% of the base price plus topping
price
Here is a compiled Python program you can download and run to see
what kind of interface you should have:
pizza.pyc
Save your source code as
hw03-xxx.py (where
xxx are your initials) and submit it via email as described
at the top of this page.
Hw02: Compound Interest (due 1/27))
Write a program that will display the future value of an
investment that pays fixed interest, compounded monthly, for a
specified number of months. Prompt the user to input the principal
(amount deposited), term (in months), and an annual
interest rate (in percent). The formula for future value (fv)
at the end of any month t, with a principal p and a
compound monthly interest rate of r is:
fv = p(1 + r)t
When implementing this formula in Python, remember that there is
no implied multiplication, r must be converted from an annual
to a monthly rate and expressed as a decimal (not a percentage).
Your program should have three functions:
- main( ): Execution starts here
- splash( ): Displays a "splash screen" with program
description
- fv( ): Calculates and returns the future value, given
principal, term, and interest rate
The structure of your program should be similar to this:
# hw02-jja.py -- 100127 (John
J. Astor)
# Compute future value of an investment
def main():
splash()
# input user values here (principal, rate, & term)
# call fv to get future value and display it
raw_input("Press <Enter> to exit.") # hold window
def splash():
# display program splash screen
def fv(p, r, t):
# calculate and return fv
main() # start the program!
|
Here is a sample executable (download it by right-click, save it,
double-click to run on a computer with Python installed):
cdcalc.pyc
Save and submit your program with the filename
hw02-xxx.py, where
xxx are your initials.
Hw01: Simple IPO
Conversion Program (due 1/20)
Using the Python IDLE Tutorial
program (in2cm.py) as a model, write a
program to convert between two other units of measure (for example,
miles to feet, gallons to liters, light years to parsecs, etc.).
Make sure you read and follow the homework
guidelines. Your program documentation (comments), variable
names, and user prompts should be appropriate for your conversion.
For an extra challenge (not extra credit!), write the program so
it converts the input into two (or more) other units of measure. For
example, convert pounds to kilograms and stones.
Save and submit your program with the filename
Hw01-xxx.py, where
xxx are your initials.
|