Difference between revisions of "CSC111 Lab 10 2014"

From dftwiki3
Jump to: navigation, search
(Challenge 2)
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 13:39, 7 April 2014 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 13:39, 7 April 2014 (EDT)
 
----
 
----
 +
<br />
 +
<bluebox>
 +
This lab presents some exercises on exceptions and '''O'''bject-'''O'''riented '''P'''rogramming.
 +
</bluebox>
 
<br />
 
<br />
 
=Exceptions=
 
=Exceptions=
Line 8: Line 12:
 
==TypeError Exceptions==
 
==TypeError Exceptions==
 
<br />
 
<br />
The code section below should remind you of a recent homework assignmentCreate a program called '''stats.py''' with this code:
+
The code section below will be our testbed for this part of the labYou have to make it compute the different values we are interested in '''without using if/else/elif statements,''' using instead '''try/except''' statements.
  
 
<br />
 
<br />
 
<br />
 
<br />
 
<source lang="python">
 
<source lang="python">
statistics = [['Afghanistan', 28710000, 'NA', 'NA', 1], ['Albania', 3580000,
+
# happiness.py
              12000, 'NA', 10], ['Algeria', 32810000, 180000, 'NA', 2],
+
# Lab 10 demo
              ['Andorra', 69150, 24500, 'NA', 1], ['Angola', 10760000,
+
 
              60000, 'NA', 1], ['Anguilla', 12738, 919, 'NA', 16],
+
SWsFriends = [
              ['Antigua_and_Barbuda', 67897, 5000, 'NA', 16], ['Argentina',
+
    # name    pocket-money  debt
              38740000, 4650000, 'NA', 33], ['Armenia', 3320000, 30000, 'NA',
+
    ("Sleepy", 10,         "NA" ),
              9], ['Aruba', 70844, 24000, 'NA', 'NA'], ['Australia', 19730000,
+
    ("Sneezy", 25.50,     0 ),
              13010000, 9020000, 571], ['Austria', 8180000, 4650000,
+
    ("Bashful", 0.50,       10.51 ),
              1300000, 37], ['Azerbaijan', 7830000, 25000, 'NA', 2],
+
    ( "Happy", 0,         0 ),
              ['Bahrain', 667238, 140200, 'NA', 1], ['Bangladesh',
+
    ( "Grumpy", 0,         100.30 ),
              138440000, 150000, 'NA', 10], ['Barbados', 277264, 6000, 'NA',
+
    ( "Dopey", "NA",       0 ),
              19], ['Belarus', 10330000, 422000, 'NA', 23], ['Belgium',
+
    ( "Doc",   200,       0 ) ]
              10280000, 4870000, 1600000, 61], ['Belize', 266440, 18000,
 
              'NA', 2], ['Benin', 7040000, 25000, 'NA', 4], ['Bhutan',
 
              2130000, 2500, 'NA', 'NA'], ['Bolivia', 8580000, 78000, 'NA', 9],
 
              ['Bosnia_and_Herzegovian', 3980000, 45000, 'NA', 3],
 
              ['Botswana', 1570000, 33000, 'NA', 11], ['Brazil', 182030000,
 
              22320000, 10860000, 50], ['Brunei', 358098, 35000, 'NA', 2],
 
              ['Bulgaria', 7530000, 1610000, 'NA', 200], ['Burkina_Faso',
 
              13220000, 25000, 'NA', 1], ['Burma', 42510000, 10000, 'NA', 1],
 
              ['Burundi', 6090000, 6000, 'NA', 1], ['Cambodia', 13120000,
 
              10000, 'NA', 2], ['Cameroon', 15740000, 45000, 'NA', 1] ]
 
  
 
def main():
 
def main():
     for country, pop, users, active, isp in statistics:
+
     for name, pocket, debt in SWsFriends:
         print( "%30s (%d habitants)" % (country, pop ), end="" )
+
         print( name, "has", pocket, "dollar(s) in his pocket, and owes",
        print( "Users=", users, " Active=", active, " ISP=", isp )
+
                debt, "dollar(s)" )
 
 
  
 
main()
 
main()
 
 
</source>
 
</source>
 
<br />
 
<br />
 
<br />
 
<br />
 
* Run the program.
 
* Run the program.
* Notice that the data are in their original form.  When a quantity is not known, the creators of the list use '''"NA"''' to indicate that it was '''N'''ot '''A'''vailable.
+
* Notice that some amounts of money have "NA" as a value (Not Available).
  
* Let's compute the total population of the (partial) list of countries in the list '''statistics'''.
+
* Add a for-loop to your program that will add up the total amount of money Snow White's friends have in their pocket.
 +
Do not anticipate errors.  <font color="magenta">Just go for it!</font>  Assume there won't be errors and put all the code necessary to compute the sum of all the numbers in the 2nd column.
  
    count = 0
+
* When you run your program the first time, you will get a <font color="red">TypeError</font> because you cannot take the '''float( )''' of the string '''"NA"'''.  Add a '''try/except''' clause around the addition, as illustrated below:
    for country, pop, users, active, isp in statistics:
 
          count += pop
 
  
:Go ahead and see if your get a total population of 618039669.
 
 
<br />
 
<br />
 +
<source lang="python">
 +
    try:
 +
        sumPocket += pocket
 +
    except TypeError:
 +
        continue
 +
</source>
 +
<br />
 +
 +
* Run your program again.  Verify that you get the total sum in all the pockets (we assume that NA will be equivalent to 0).
 +
 +
<font color="blue">total sum in all the pockets:  236.0</font>
 +
 +
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 
{| style="width:100%; background:silver"
 
{| style="width:100%; background:silver"
 
|-
 
|-
 
|
 
|
  
===Challenge #1===
+
==Challenge 1==
 
|}
 
|}
 
[[Image:QuestionMark1.jpg|right|120px]]
 
[[Image:QuestionMark1.jpg|right|120px]]
 
<br />
 
<br />
* Modify your program so that it also computes the total number of Users.  Make it use the very same construct as shown above, but now for the quantity '''users'''.
+
* Add a new loop that computes the total amount of debts held by the 7 friends.
 
+
* Do not use if statementsUse a new try/except clause to protect your code from exceptions.
* Run your program.
+
<br />
 
 
* Did you get an error of this type?
 
 
 
  <font color="red">Traceback (most recent call last):
 
  File "stats.py", line 36, in <module>
 
  &nbsp;&nbsp;&nbsp;&nbsp;  main()
 
  File "stats.py", line 31, in main
 
  &nbsp;&nbsp;&nbsp;&nbsp;  userCount += users
 
TypeError: unsupported operand type(s) for +=: 'int' and 'str'</font>
 
 
 
:If so, why?  What made the program crash? 
 
:Think hard!
 
:Harder!
 
 
<br />
 
<br />
 
<br />
 
<br />
 
<br />
 
<br />
 
<br />
 
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 +
{| style="width:100%; background:silver"
 +
|-
 +
|
 +
 +
==Challenge 2==
 +
|}
 +
[[Image:QuestionMark3.jpg|right|120px]]
 
<br />
 
<br />
 +
* Make your program print the contents of the list in 3 columns, as shown below. Use a print format containing "%f" type commands for the floats:
 
<br />
 
<br />
<center>[[Image:FrogThinking.jpg | 200px]]</center>
+
<source lang="text">
 +
    Sleepy  10.00      NA
 +
    Sneezy  25.50    0.00
 +
  Bashful    0.50  10.51
 +
    Happy    0.00    0.00
 +
    Grumpy    0.00  100.30
 +
    Dopey      NA    0.00
 +
      Doc  200.00    0.00
 +
</source>
 
<br />
 
<br />
 
<br />
 
<br />
 +
'''Note''': you may be tempted to code the output as follows:
 
<br />
 
<br />
 +
::<source lang="python">
 +
print( "%20s %10.2f %10.2f" % ( name, pocket, debt ) )
 +
</source>
 
<br />
 
<br />
 +
but it may be easier to decompose it in several steps:
 
<br />
 
<br />
 +
::<source lang="python">
 +
s1 = "%20s" % name
 +
s2 = "%10.2f" % pocket
 +
s3 = "%10.2f" % debt
 +
print( s1, s2, s3 )
 +
</source>
 
<br />
 
<br />
:Do not move on until you know for sure why this error was generated.
+
 
 +
==Be Friendly! Print an Error Message for the User!==
 
<br />
 
<br />
 +
When you catch an exception, the '''catch TypeError''' type of statement indicates some like "''if there is an exception of type '''TypeError''', then...''  But that does there is actually an object of type '''TypeError''', an we can ask Python to give it to us, if we want to.  The way to do this is to write:
 +
 
<br />
 
<br />
 +
<source lang="python">
 +
except TypeError as err:
 +
    ...
 +
</source>
 
<br />
 
<br />
 +
in this case, '''err''' is the object of type '''TypeError'''.  Most objects of this type have a member variable called args, which is a list of arguments, and which includes the description of the error in the first location.  So to print it, one would simply do this:
 
<br />
 
<br />
 +
<source lang="python">
 +
except TypeError as err:
 +
        print( "*** ERROR ***", err.args[0] )
 +
</source>
 
<br />
 
<br />
 +
The full program would look something like this:
 
<br />
 
<br />
 +
<source lang="python">
 +
SWsFriends = [
 +
    # name    pocket-money  debt
 +
    ("Sleepy",  10,        "NA" ),
 +
    ("Sneezy",  25.50,      0 ),
 +
    ("Bashful", 0.50,      10.51 ),
 +
    ( "Happy",  0,          0 ),
 +
    ( "Grumpy", 0,          100.30 ),
 +
    ( "Dopey",  "NA",      0 ),
 +
    ( "Doc",    200,        0 ) ]
  
* I trust that if you are reading this, it is because you know what caused your program to crash.  The clue is '''unsupported operand type(s) for +=: 'int' and 'str' ''', indicating that we are trying to add ''' 'NA' ''' which is a string to '''count''', which is an integer.
 
  
:We could use an if statement to test whether '''users''' contains 'NA' or not, but we'll use another approach.  We will tell python to '''try''' adding '''users''' to the counting variable, and if there is an error of type '''TypeError''' (see the last ligne of the error message when the program crashed), then we won't add anything to the count variable; we'll just ''pass''.
+
sumPocket = 0
 +
for name, pocket, debt in SWsFriends:
 +
    try:
 +
        sumPocket += pocket
 +
    except TypeError as err:
 +
        print( err.args[0] )
 +
        continue
  
:The main program becomes:
+
print( "total sum in all pockets: ", sumPocket )
::<source lang="python">
 
def main():
 
    popCount = 0
 
    userCount = 0
 
    for country, pop, users, active, isp in statistics:
 
        print "%30s (%d habitants)" % (country, pop ),
 
        print "Users=", users, " Active=", active, " ISP=", isp
 
        popCount += pop
 
        try:
 
            userCount += users
 
        except TypeError:
 
            # don't do anything
 
            pass
 
    print "total population = ", popCount
 
    print "total users      = ", userCount
 
 
</source>
 
</source>
 
<br />
 
<br />
* Try it!
+
 
* Use the same method to compute the total number of ISPs.
+
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 +
{| style="width:100%; background:silver"
 +
|-
 +
|
 +
 
 +
==Challenge 3==
 +
|}
 +
[[Image:QuestionMark3.jpg|right|120px]]
 +
<br />
 +
* Update your program and make it print the error string associated with the exception whenever one occurs.  
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 
<br />
 
<br />
==Other Exceptions==
+
 
 +
=Object Oriented Programming (OOP)=
 
<br />
 
<br />
* Imagine that now the list '''statistics''' is defined as shown below, and that for some countries the ISP value (the last one) is missing:
+
==Part 1: List of People==
 
<br />
 
<br />
<source lang="python">
+
* Create a [[CSC111_Simple_Programs_Introducing_OOP#Same_Program.2C_using_OOP| copy of the OOP program we saw in class]]
 +
* Run it.  Make sure you understand how the code works, and that you understand its output.
 +
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 +
{| style="width:100%; background:silver"  
 +
|-
 +
 +
==Challenge 4==
 +
|}
 +
[[Image:QuestionMark4.jpg|right|120px]]
 +
<br />
 +
* Modify the program and make it ask the user for the information about a new student, and add this student to the list.  Print the list at the end.
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 +
{| style="width:100%; background:silver"
 +
|-
 +
 +
==Challenge 5==
 +
|}
 +
[[Image:QuestionMark5.jpg|right|120px]]
 +
<br />
 +
* Play with this code in the console:
 +
 +
>>> L = [30, 50, 20, 10, 100]
 +
>>> L.pop( 2 )
 +
>>> L
 
   
 
   
statistics = [['Afghanistan', 28710000, 'NA', 'NA', 1], ['Albania', 3580000,
+
* Once you figured out how '''pop()''' works on a list, make your program ask for a student name, and then remove (pop) that student from the list.
                12000, 'NA', 10], ['Algeria', 32810000, 180000, 'NA'],
+
<br />
                ['Andorra', 69150, 24500, 'NA', 1], ['Angola', 10760000,
+
<br />
                60000, 'NA', 1], ['Anguilla', 12738, 919, 'NA', 16],
+
<br />
                ['Antigua_and_Barbuda', 67897, 5000, 'NA', 16], ['Argentina',
+
<br />
                38740000, 4650000, 'NA', 33], ['Armenia', 3320000, 30000, 'NA',
+
<br />
                9], ['Aruba', 70844, 24000, 'NA' ], ['Australia', 19730000,
+
<br />
                13010000, 9020000, 571], ['Austria', 8180000, 4650000,
 
                1300000, 37], ['Azerbaijan', 7830000, 25000, 'NA'],
 
                ['Bahrain', 667238, 140200, 'NA', 1], ['Bangladesh',
 
                138440000, 150000, 'NA', 10], ['Barbados', 277264, 6000, 'NA',
 
                19], ['Belarus', 10330000, 422000, 'NA', 23], ['Belgium',
 
                10280000, 4870000, 1600000, 61], ['Belize', 266440, 18000,
 
                'NA', 2], ['Benin', 7040000, 25000, 'NA', 4], ['Bhutan',
 
                2130000, 2500, 'NA', 'NA'], ['Bolivia', 8580000, 78000, 'NA', 9],
 
                ['Bosnia_and_Herzegovian', 3980000, 45000, 'NA', 3],
 
                ['Botswana', 1570000, 33000, 'NA', 11], ['Brazil', 182030000,
 
                22320000, 10860000, 50], ['Brunei', 358098, 35000, 'NA', 2],
 
                ['Bulgaria', 7530000, 1610000, 'NA', 200], ['Burkina_Faso',
 
                13220000, 25000, 'NA'], ['Burma', 42510000, 10000, 'NA', 1],
 
                ['Burundi', 6090000, 6000, 'NA', 1], ['Cambodia', 13120000,
 
              10000, 'NA', 2], ['Cameroon', 15740000, 45000, 'NA', 1] ]
 
  
</source>
+
==Part 2: A List of Dogs==
 +
[[Image:dogCartoon.jpg|200px|right]]
 
<br />
 
<br />
* Write a program (or copy/paste part of the previous one) that will read the list above, and output the total population (which should be the same as before).
+
* Using the '''Person''' class as an example, create a new class that will be called '''Dog'''.  This class will contain some information one may find useful to associate with a dog, i.e.:
** For this you should write your program as if all the country lists contained 5 quantities.
+
** a tag name (string)
** Then you run your program.
+
** the age (int)
** You observe that it crashes when it tries to extract the 5th quantity from a country list.
+
** whether it is vaccinated (boolean)
** You note the name of the error generated (which is on the last line, and usually of the form '''XxxxError''',  such as '''IndexError''', '''TypeError''', '''NameError''', '''ValueError''', etc.)
+
** the breed (string)
** Add a '''try/except''' statement around the code that generates the error (Python refers to a run-time error that creates a crash as an ''exception''):
 
 
<br />
 
<br />
<source lang="python">
+
*Add a dog to the list using the simplest way, illustrated below:
      try:
+
<br />
          country, pop, users, active, isp = someVariableOfYours
+
::<source lang="python">
      except XxxxError:
+
 
          country, pop, users, active = someVariableOfYours
+
    dogs.append(  Dog( "Rex", 4, True, "German Shepherd" ) )
 +
 
 
</source>
 
</source>
 
<br />
 
<br />
:: Run your program again and observe that it doesn't crash and that it reports the correct information.
+
* Make your program display this list of one dog.  This will require your having created a method called ''toString()'' that will return a string with the dog information in it.   Here's an example of a possible string returned by this method:
 +
 
 +
    'Rex, 4 years old, vaccinated, German Shepherd'
 +
 
  
 +
* When this works, add three more dogs to the list.  Make some of them vaccinated, some not vaccinated.  Also make a couple of dogs the same breed (In case you need help finding breeds, check this [http://www.petfinder.com/dog-breeds/ page] out).  Make sure the program displays the list correctly.
 +
<br />
 +
<!-- ----------------------------------------------------------------------------------------------- -->
 +
{| style="width:100%; background:silver"
 +
|-
 +
|
  
 +
==Challenge 6==
 +
|}
 +
[[Image:QuestionMark6.jpg|right|120px]]
 +
<br />
 +
* Add some code to your program that will display only the dogs that are vaccinated.
 +
* Add some more code that will display all the dogs of a given breed.  Pick the breed that you know has more than one representatives in your list.
 
<br />
 
<br />
 +
Below is an output showing a possible way for your program to behave:
 +
<br />
 +
List of 1 dog
 +
Rex, 4 years old, vaccinated, German Shepherd
 +
 +
List of 4 dogs
 +
Rex, 4 years old, vaccinated, German Shepherd
 +
Fifi, 1 years old, not vaccinated, Poodle
 +
Samson, 3 years old, vaccinated, Great Dane
 +
Mad Max, 2 years old, not vaccinated, Poodle
 +
 +
The vaccinated dogs are:
 +
Rex, 4 years old, vaccinated, German Shepherd
 +
Samson, 3 years old, vaccinated, Great Dane
 +
 +
Please enter a breed: Great Dane
 +
Dogs of breed Great Dane
 +
Samson, 3 years old, vaccinated, Great Dane
 +
 +
 +
=Submission=
 +
<br />
 +
Submit the program (which you should name '''lab10.py''') to this URL: [http://cs.smith.edu/~thiebaut/111b/submitL10.php  http://cs.smith.edu/~thiebaut/111b/submitL10.php]
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
 +
 +
<br /> <br /> <br /> <br /> <br /> <br />
 +
[[Category:CSC111]][[Category:Python]][[Category:Labs]]

Latest revision as of 10:41, 10 April 2014

--D. Thiebaut (talk) 13:39, 7 April 2014 (EDT)



This lab presents some exercises on exceptions and Object-Oriented Programming.


Exceptions


If you feel you have a good handle on exceptions, then move on to the next section. Otherwise do the exercises of this section.

TypeError Exceptions


The code section below will be our testbed for this part of the lab. You have to make it compute the different values we are interested in without using if/else/elif statements, using instead try/except statements.



# happiness.py
# Lab 10 demo

SWsFriends = [
    # name    pocket-money  debt
    ("Sleepy",  10,         "NA" ),
    ("Sneezy",  25.50,      0 ),
    ("Bashful", 0.50,       10.51 ),
    ( "Happy",  0,          0 ),
    ( "Grumpy", 0,          100.30 ),
    ( "Dopey",  "NA",       0 ),
    ( "Doc",    200,        0 ) ]

def main():
    for name, pocket, debt in SWsFriends:
        print( name, "has", pocket, "dollar(s) in his pocket, and owes",
                debt, "dollar(s)" )

main()



  • Run the program.
  • Notice that some amounts of money have "NA" as a value (Not Available).
  • Add a for-loop to your program that will add up the total amount of money Snow White's friends have in their pocket.

Do not anticipate errors. Just go for it! Assume there won't be errors and put all the code necessary to compute the sum of all the numbers in the 2nd column.

  • When you run your program the first time, you will get a TypeError because you cannot take the float( ) of the string "NA". Add a try/except clause around the addition, as illustrated below:


    try:
        sumPocket += pocket
    except TypeError:
        continue


  • Run your program again. Verify that you get the total sum in all the pockets (we assume that NA will be equivalent to 0).
total sum in all the pockets:  236.0


Challenge 1

QuestionMark1.jpg


  • Add a new loop that computes the total amount of debts held by the 7 friends.
  • Do not use if statements. Use a new try/except clause to protect your code from exceptions.






Challenge 2

QuestionMark3.jpg


  • Make your program print the contents of the list in 3 columns, as shown below. Use a print format containing "%f" type commands for the floats:


    Sleepy   10.00      NA
    Sneezy   25.50    0.00
   Bashful    0.50   10.51
     Happy    0.00    0.00
    Grumpy    0.00  100.30
     Dopey      NA    0.00
       Doc  200.00    0.00



Note: you may be tempted to code the output as follows:

print( "%20s %10.2f %10.2f" % ( name, pocket, debt ) )


but it may be easier to decompose it in several steps:

s1 = "%20s" % name
s2 = "%10.2f" % pocket
s3 = "%10.2f" % debt
print( s1, s2, s3 )


Be Friendly! Print an Error Message for the User!


When you catch an exception, the catch TypeError type of statement indicates some like "if there is an exception of type TypeError, then... But that does there is actually an object of type TypeError, an we can ask Python to give it to us, if we want to. The way to do this is to write:


 except TypeError as err:
     ...


in this case, err is the object of type TypeError. Most objects of this type have a member variable called args, which is a list of arguments, and which includes the description of the error in the first location. So to print it, one would simply do this:

 except TypeError as err:
        print( "*** ERROR ***", err.args[0] )


The full program would look something like this:

SWsFriends = [
    # name    pocket-money  debt
    ("Sleepy",  10,         "NA" ),
    ("Sneezy",  25.50,      0 ),
    ("Bashful", 0.50,       10.51 ),
    ( "Happy",  0,          0 ),
    ( "Grumpy", 0,          100.30 ),
    ( "Dopey",  "NA",       0 ),
    ( "Doc",    200,        0 ) ]


sumPocket = 0
for name, pocket, debt in SWsFriends:
    try:
        sumPocket += pocket
    except TypeError as err:
        print( err.args[0] )
        continue

print( "total sum in all pockets: ", sumPocket )



Challenge 3

QuestionMark3.jpg


  • Update your program and make it print the error string associated with the exception whenever one occurs.







Object Oriented Programming (OOP)


Part 1: List of People



Challenge 4

QuestionMark4.jpg


  • Modify the program and make it ask the user for the information about a new student, and add this student to the list. Print the list at the end.








Challenge 5

QuestionMark5.jpg


  • Play with this code in the console:
>>> L = [30, 50, 20, 10, 100]
>>> L.pop( 2 ) 
>>> L

  • Once you figured out how pop() works on a list, make your program ask for a student name, and then remove (pop) that student from the list.







Part 2: A List of Dogs

DogCartoon.jpg


  • Using the Person class as an example, create a new class that will be called Dog. This class will contain some information one may find useful to associate with a dog, i.e.:
    • a tag name (string)
    • the age (int)
    • whether it is vaccinated (boolean)
    • the breed (string)


  • Add a dog to the list using the simplest way, illustrated below:


    dogs.append(  Dog( "Rex", 4, True, "German Shepherd" ) )


  • Make your program display this list of one dog. This will require your having created a method called toString() that will return a string with the dog information in it. Here's an example of a possible string returned by this method:
   'Rex, 4 years old, vaccinated, German Shepherd'


  • When this works, add three more dogs to the list. Make some of them vaccinated, some not vaccinated. Also make a couple of dogs the same breed (In case you need help finding breeds, check this page out). Make sure the program displays the list correctly.


Challenge 6

QuestionMark6.jpg


  • Add some code to your program that will display only the dogs that are vaccinated.
  • Add some more code that will display all the dogs of a given breed. Pick the breed that you know has more than one representatives in your list.


Below is an output showing a possible way for your program to behave:

List of 1 dog
Rex, 4 years old, vaccinated, German Shepherd

List of 4 dogs
Rex, 4 years old, vaccinated, German Shepherd
Fifi, 1 years old, not vaccinated, Poodle
Samson, 3 years old, vaccinated, Great Dane
Mad Max, 2 years old, not vaccinated, Poodle

The vaccinated dogs are: 
Rex, 4 years old, vaccinated, German Shepherd
Samson, 3 years old, vaccinated, Great Dane

Please enter a breed: Great Dane
Dogs of breed Great Dane
Samson, 3 years old, vaccinated, Great Dane

Submission


Submit the program (which you should name lab10.py) to this URL: http://cs.smith.edu/~thiebaut/111b/submitL10.php