# COP2002 Project 1 to 10 solutions

\$170.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

5/5 - (1 vote)

## COP2002 Project 2-1: Student Registration

Create a program that allows a student to complete a registration form and displays a
completion message that includes the user’s full name and a temporary password.
Console
Student Registration
First name: Eric
Last name: Idle
Birth year: 1934
Welcome Eric Idle!
Your registration is complete.
Specifications
 The user’s full name consists of the user’s first name, a space, and the user’s last name.
 The temporary password consists of the user’s first name, an asterisk (*), and the user’s birth year.
 Assume the user will enter valid data.
 Save the file with the filename registration_XXX.py where XXX is either your initials or your last
name.

## COP2002 Project 3-1: Change Calculator

Create a program that calculates the coins needed to make change for a specified
monetary amount.
Console
Change Calculator
Enter dollar amount (for example, .56, 7.85): 3.37
Quarters: 13
Dimes: 1
Nickels: 0
Pennies: 2
Continue? (y/n): y
Enter dollar amount (for example, .56, 7.85): .55
Quarters: 2
Dimes: 0
Nickels: 1
Pennies: 0
Continue? (y/n): X
please enter y or n
Continue? (y/n): n
Bye!
Specifications
• The program should display the minimum number of quarters, dimes, nickels, and pennies that
represent the coins that make up the specified amount.
• Assume that the user will enter a valid number.
• The program should continue only if the user enters “y” or “Y” to continue.
• Save the file with the filename change_XXX.py where XXX is either your initials or your last name.

## COP2002 Project 4-1: Prime Number Checker

Create a program that checks whether a number is a prime number. The display
should include whether or not the number is prime and a list of the number’s factors. For
numbers that are not prime, also include the number of factors for that number.
Console
Prime Number Checker
Please enter an integer between 1 and 5,000: 7
The factors of your number are:
1
7
7 is a prime number.
Try again? (y/n): y
Please enter an integer between 1 and 5,000: 12
The factors of your number are:
1
2
3
4
6
12
12 is NOT a prime number.
It has 6 factors.
Try again? (y/n): n
Specifications
 A prime number is divisible by two factors (1 and itself). For example, 7 is a prime number because it
is only divisible by 1 and 7.
 If the number is prime, the program should display its factors (1 and the number itself).
 If the number is not a prime number, the program should display the factors and its number of factors.
 Store the code that gets a valid integer for this program in its own function.
 Store the code that calculates the number of factors and displays the factors for a number in a
function.
 Store the rest of the code that gets input and displays output in the main function.
 Save the file with the filename primes_XXX.py where XXX is either your initials or your last name.

## COP2002 Project 5-1: Debug the Guessing Game

Open the program named p5-1_guesses_errors.py which is in the Module 5 area.
Find and fix all of the errors that it contains. Be sure to fill in the list of errors you found
in the comment area in that file. When you’re done, the program should run as shown
below
Console
Guess the number!
Enter the upper limit for the range of numbers: 100
I’m thinking of a number from 1 to 100.
Too low.
Too low.
Too low.
Too low.
Too high.
Too low.
You guessed it in 7 tries.
Play again? (y/n): y
Enter the upper limit for the range of numbers: 10
I’m thinking of a number from 1 to 10.
Too low.
Too low.
Too low.
You guessed it in 4 tries.
Play again? (y/n): n
Bye!
Specifications
 Save the corrected file with the filename guessing_game_XXX.py where XXX is either your initials
or your last name.

## COP2002 Project 6-1: Wizard Inventory

Create a program that keeps track of the items that a wizard can carry.
Console
The Wizard Inventory program
show – Show all items
grab – Grab an item
edit – Edit an item
drop – Drop an item
exit – Exit program
Command: show
1. wooden staff
2. wizard hat
3. cloth shoes
Command: grab
Name: potion of invisibility
potion of invisibility was added.
Command: grab
You can’t carry any more items. Drop something first.
Command: show
1. wooden staff
2. wizard hat
3. cloth shoes
4. potion of invisibility
Command: edit
Number: 1
Updated name: magic wooden staff
Item number 1 was updated.
Command: drop
Number: 3
cloth shoes was dropped.
Command: exit
Bye!
Specifications
 Use a list to store the items. Provide three starting items.
 The wizard can only carry four items at a time.
 For the edit and drop commands, display an error message if the user enters an invalid number.
 When you exit the program, all changes that you made to the contact list are lost.
 Store the rest of the code that gets input and displays output in the main function.
 Save the file with the filename wizard_inventory_XXX.py where XXX is either your initials or your
last name.

## COP2002 Project 7-1: Contact Manager

Create a program that a user can use to manage the primary email address and phone
number for a contact. To get you started, download and use the file named contacts.csv
which is in the Module 7 area. You do not need to upload the contacts.csv file with your
homework submission.
Console
Contact Manager
list – Display all contacts
view – View a contact
del – Delete a contact
exit – Exit program
Command: list
1. Guido van Rossum
2. Eric Idle
3. Lizard Duck
4. Morris Feline
Name: Alice Carroll
Email: alice@wonderland.com
Phone: 352-555-9876
Alice Carroll was added.
Command: list
1. Guido van Rossum
2. Eric Idle
3. Lizard Duck
4. Morris Feline
5. Alice Carroll
Command: exit
Bye!
Specifications
 For the view and del commands, display an error message if the user enters an invalid contact
number.
 Use the contacts.csv file to store the data for the program.
 When you start the program, it should read the contacts from the CSV file.
 When you add or delete a contact, the change should be saved to the CSV file immediately. That way,
no changes are lost, even if the program crashes later.
 Note: you must close the CSV file before running the program or it will not work.
 Save the file with the filename contacts_XXX.py where XXX is either your initials or your last name.

## COP2002 Project 8-1: Contact Manager with exception handling

Add exception handling to the contacts program that manages the primary email
address and phone number for a contact, from Module 7.
Console
Could not find contacts file!
Starting new contacts file…
Contact Manager
list – Display all contacts
view – View a contact
del – Delete a contact
exit – Exit program
Command: list
There are no contacts in the list.
Name: Bugsy Lapin
Email: blapin@bunnies.org
Phone: 352-555-2468
Bugsy Lapin was added.
Command: view
Number: 8
Invalid contact number.
Command: view
Number: B
Invalid integer.
Command: view
Number: 1
Name: Bugsy Lapin
Email: blapin@bunnies.org
Phone: 352-555-2468
Specifications
 When you start the program, it should read the contacts from a CSV file.
 If the program can’t find the CSV file, it should display an appropriate message and create a new
CSV file that doesn’t contain any contact data.
 For the view and del commands, display an appropriate error message if the user enters an invalid
integer or an invalid contact number.
 When you add or delete a contact, the change should be saved to the CSV file immediately.
 Save the file with the filename contacts2_XXX.py where XXX is either your initials or your last
name.

## COP2002 Project 9-1: Monthly Payment Calculator

Create a program that calculates the monthly payments on a loan
Console
Monthly Payment Calculator
DATA ENTRY
Loan amount: 500000
Yearly interest rate: 5.6
Years: 30
FORMATTED RESULTS
Loan amount: \$500,000.00
Yearly interest rate: 5.6%
Number of years: 30
Monthly payment: \$2,870.39
Continue? (y/n): y
DATA ENTRY
Loan amount: 500000
Yearly interest rate: 4.3
Years: 30
FORMATTED RESULTS
Loan amount: \$500,000.00
Yearly interest rate: 4.3%
Number of years: 30
Monthly payment: \$2,474.36
Continue? (y/n): n
Specifications
 The interest rate should only have one decimal place for both the calculation and the formatted
results.
 The formula for calculating monthly payment is:
month_payment = loan_amount * monthly_interest_rate / (1 – 1 / (1 + monthly_interest_rate) ** months)
 Use the locale module to ensure the results are formatted for the proper location.
 Use the decimal module and its quantize() method for rounding.
 Assume that the user will enter valid data.
 Save the file with the filename month_payment_XXX.py where XXX is either your initials or your
last name.
Hint
 You may find the Future Value program on pp. 264-265 of the textbook to be helpful.

## COP2002 Project 10-1: Pig Latin Translator

Create a program that translates English to Pig Latin.
Console
Pig Latin Translator
Enter text: Tis but a scratch.
English: tis but a scratch
Pig Latin: istay utbay away atchscray
Continue? (y/n): y
Enter text: We are the knights who say nee!
English: we are the knights who say nee
Pig Latin: eway areway ethay ightsknay owhay aysay eenay
Continue? (y/n): n
Specifications
 Convert the English to lowercase before translating.
 Remove any punctuation characters before translating.
 Assume that words are separated from each other by a single space.
 If the word starts with a vowel, just add way to the end of the word.
 If the word starts with a consonant, move all of the consonants that appear before the first vowel to
the end of the word, then add ay to the end of the word.
 If a word starts with the letter y, the y should be treated as a consonant. If the y appears anywhere else
in the word, it should be treated as a vowel.
 Save the file with the filename pig_latin_XXX.py where XXX is either your initials or your last
name.
Note:
 There are no official rules for Pig Latin. Most people agree on how words that begin with consonants
are translated, but there are many different ways to handle words that begin with vowels.

## COP2002 Project 11-1: Arrival Time Estimator

Create a program that calculates the estimated hours and minutes for a trip. This
should include an estimated date/time of departure and an estimated date/time of arrival.
Console
Arrival Time Estimator
Estimated date of departure (YYYY-MM-DD): 2018-11-23
Estimated time of departure (HH:MM AM/PM): 10:30 AM
Enter miles: 200
Enter miles per hour: 65
Estimated travel time
Hours: 3
Minutes: 4.62
Estimated date of arrival: 2018-11-23
Estimated time of arrival: 01:34 PM
Continue? (y/n): y
Estimated date of departure (YYYY-MM-DD): 2018-11-29
Estimated time of departure (HH:MM AM/PM): 11:15 PM
Enter miles: 500
Enter miles per hour: 80
Estimated travel time
Hours: 6
Minutes: 15.0
Estimated date of arrival: 2018-11-30
Estimated time of arrival: 05:30 AM
Continue? (y/n): n
Specifications
• For the date/time of departure and arrival, the program should use the YYYY-MM-DD format for
dates and the HH:MM AM/PM format for times.
• For the miles and miles per hour, the program should only accept integer entries like 200 and 65.
• Assume that the user will enter valid data.
• Save the file with the filename arrival_XXX.py where XXX is either your initials or your last name.
Bonus: +25 points
• If you add the following to your program, your grade on this program can be as high as 125%. This