Difference between revisions of "CSC111 Final Exam 2014"

From dftwiki3
Jump to: navigation, search
Line 16: Line 16:
  
 
<br />
 
<br />
 +
=Problem #1=
 +
<br />
 +
<source lang="python">
 +
 +
text = """person, Marion, 31, married, Amherst, Marion887@gmail.com
 +
person, George, 66, single, Cambridge, George113@gmail.com
 +
person, Alexandra, 79, single, Northampton, Alexandra2013yoyo@gmail.com
 +
person, Francis, 79, single, Northampton, Francis2013yoyo@gmail.com
 +
person, Cesca, 55, married, Amherst, Cesca2013yoyo@gmail.com
 +
person, Stella, 31, single, Boston, Stella113@gmail.com
 +
person, Alma, 20, single, Cambridge, Alma2013yoyo@gmail.com
 +
dog, Miko, 4, Australian Shepherd, vaccinated, not trained, tattooed, Cesca
 +
dog, Fido, 4, Australian Shepherd, not vaccinated, not trained, not tattooed, Stella
 +
dog, Max, 3, Australian Shepherd, not vaccinated, trained, not tattooed, Francis
 +
dog, Bergere, 4, Australian Shepherd, vaccinated, not trained, tattooed, Marion
 +
dog, Mika, 1, Beagle, vaccinated, not trained, tattooed, Stella
 +
dog, Luna, 1, Terrier, vaccinated, not trained, not tattooed, Alma
 +
dog, Bella, 3, Akita, not vaccinated, not trained, not tattooed, Stella
 +
dog, Rintintin, 2, Terrier, not vaccinated, trained, tattooed, Marion
 +
dog, Oscar, 4, Beagle, not vaccinated, not trained, tattooed, Alexandra
 +
dog, Mirabelle, 4, Beagle, vaccinated, trained, not tattooed, Alexandra
 +
cat, Jabba, 3, Poodle, vaccinated, outdoors, not tattooed, Francis
 +
cat, Yago, 3, Terrier, vaccinated, outdoors, tattooed, George
 +
cat, Calico, 5, Poodle, not vaccinated, indoors, not tattooed, Alexandra
 +
cat, Callas, 4, Terrier, not vaccinated, outdoors, tattooed, George"""
 +
</source>
 +
<br />
 +
The list above is a list of people, dogs, and cats.
 +
=Your Assignment=
 +
<br />
 +
Write a program that will read this string, parse it, store it in some data structure, and output the answers to the following questions:
 +
;Question 1
 +
:Print a list of all the people, nicely formatted, followed by a list of the dogs, followed by a list of the cats.  An example of the format to use is shown below:
 +
   
 +
  George (George113@gmail.com), 66 years old, single, lives in Cambridge
 +
  Mirabelle (dog),  4 years old, Beagle, vaccinated, trained, not tattooed, (owner: Alexandra)
 +
  Calico (cat), 5 years old, Poodle, not vaccinated, indoors, not tattooed, (owner: Alexandra)
 +
 +
;Question 2
 +
:Print the name of the people only using the format shown above, and follow each one by the number of dogs or cats he or she owns.  Example:
 +
 +
  Alexandra (Alexandra2013yoyo@gmail.com), 79 years old, single, lives in Northampton, 2 dogs, 1 cat
 +
 +
:If the person does not own pets, then do not add anything after the city where they live.
 +
 +
;Question 3
 +
: Print the name and city only of all the owners of Australian Shepherd dogs.
 +
 +
;Question 4
 +
: Print the name and city only of the owner or owners of the oldes dog
 +
 +
;Question 5
 +
: Print the name and city of the owners with the most pets
 +
 +
;Question 6
 +
: Print the email addresses of all the people who have unvaccinated pets, so that we can remind them to have them vaccinated.
 +
  
  
  
 
</onlydft>
 
</onlydft>

Revision as of 16:07, 25 April 2014


...