mith College Computer Science Lecture Notes Week 11 Everyday Python CSC111 Spring 2015 Dominique Thiébaut

Similar documents
Presidents of the United States Cards

Presidential term: Lived: Occupations: Planter, Lawyer. Vice Presidents: Aaron Burr, George Clinton

LSP In-Class Activity 5 Working with PASW 20 points Due by Saturday, Oct. 17 th 11:59 pm ANSWERS

SS7 CIVICS, CH. 8.1 THE GROWTH OF AMERICAN PARTIES FALL 2016 PP. PROJECT

Presidential Project

Expansion and Reform. (Early 1800s-1861) PRESIDENTS OF THE UNITED STATES. By Daniel Casciato

Research Skills. 2010, 2003 Copyright by Remedia Publications, Inc. All Rights Reserved. Printed in the U.S.A.

Solutions. Algebra II Journal. Module 3: Standard Deviation. Making Deviation Standard

Post-War United States

Contemporary United States

U. S. Presidents Nomenclature and Matching Cards

The Federalist Era:

Puzzles, games, and trivia for hours of presidential fun! Brian Thornton

Museum of World Treasures

About the Survey. Rating and Ranking the Presidents

ERA OF GOOD FEELINGS

no prerequisites Required Readings no textbook Recommended Readings

American Presidential Elections. The American presidential election system has produced some interesting quirks, such as...

American Presidents American Presidents

Mountain Green Elementary School 5 th Grade Great American Award

CRS-2 Currently, only 10 of the 37 presidential grave sites are maintained by the federal government. 3 Due to the high number of privately managed pr

WikiLeaks Document Release

Presidents of the United States

Thomas Jefferson

White House Transitions Fact Sheet Compiled November 2016

CRS Report for Congress Received through the CRS Web

1856 Presidential Election. James Buchanan John C. Frémont Millard Fillmore Democrat Republican Whig

EXPERIENCE AND THE PRESIDENCY

HISTORY & GEOGRAPHY STUDENT BOOK. 12th Grade Unit 3

Regular Vetoes and Pocket Vetoes: An Overview

INR 3102-U01 (16832) American Foreign Policy Spring 2019 MWF 10am PC214 Prof. Breslin SIPA 428 Office hours: WF 2-4 pm and by app t.

PRICES REALIZED DETAIL - Historical - Spring 2016 Auction 84, Auction Date:

APUSH 4/13/16. Agenda: HW: Turn in Ford Chart SA Test Carter Notes. Study for Test Terms Shirt Money Extra Credit

Regular Vetoes and Pocket Vetoes: An Overview

329520_WEBAP_pA1-A13.qxd 12/14/06 10:58 AM Page A-1. An American Profile: The United States and Its People

Introductory Text. Standards. Before Reading. During Reading. After Reading. Constitution and Government Unit

Presidential Greatness & Political Science: Assessing the 2014 APSA Presidents & Executive Politics Section Presidential Greatness Survey

Ch 40. The Reagan Revolution and Cold War:

Manifest Destiny in the 1840s

Regular Vetoes and Pocket Vetoes: In Brief

Duration of Representatives Incumbency in the U. S. House

We ve looked at presidents as individuals - Now,

CRS Report for Congress

American History Timeline

President s Swearing-In Ceremony

HOMES AND LIBRARIES OF THE PRESIDENTS

Fourth Grade Social Studies

Who was the tenth? (How old did we decide boys are when they start wearing ties?)

Election of Democrat Michael Dukakis(Mass. Gov) no

Chapter 18 Renewing the Sectional Struggle

Inauguration Fact Sheet Compiled November 2016

The Historical Experience of Experience: How and When Experience in a President Counts Charles O. Jones

ACHIEVE GREATER SUCCESS IMPROVE AND LEVERAGE YOUR LEADERSHIP STRENGTHS DAN NIELSEN

Analyzing presidential elections without incumbents. Alexander Slutsker. University of Maryland. I. Introduction

THE GREAT AMERICAN AWARD

The Constitution of the United States of America

Iowa Presidential Election Results,

The Polls: Presidential Greatness as Seen in the Mass Public: An Extension and Application of the Simonton Model

Report for Congress. Presidential and Vice Presidential Succession: Overview and Current Legislation. Updated March 25, 2003

Liberals, Conservatives, and the Presidency

The President of the United States

Franklin D. Roosevelt To George W. Bush (Education Of The Presidents) READ ONLINE

The 2014 Legislative Elections

February 2012 Newsletter: National celebration of African American History Month, President's Day, and Valentine's Day.

The Old Way ( ) 9/2/13. The Road to the White House. Nominations Primaries and Caucuses. Road to the White House Overview

Lesson Plan for United States Presidents and their Wars Timeline

Election of Worksheet #1 - Candidates and Parties. Abraham Lincoln. Stephen A. Douglas. John C. Breckinridge. John Bell

U.S. HISTORY Mr. Walter

Ch 39. The 1970s. Camp David Accords. Oil Crisis. Earth Day. President Nixon Resigns. Iran Hostage Crisis. Nixon Visits China

The University of Texas At Austin GOV312L #39030 Issues and Policies in American Government: Core Texts and Ideas in American Liberalism

BJWyler's Prediction for the winner of the 2000 Presidential Race: George W. Bush with 52% of the popular vote.

Follow this and additional works at: Part of the Political Science Commons, and the United States History Commons

the presidents E503C035A35014F7EAAAEB48935B17E8 The Presidents 1 / 6

CRS Report for Congress

Archived article from the University of North Carolina at Asheville s Journal of Undergraduate Research, retrieved from UNC Asheville s NC DOCKS

The First American Party System

A Historical Perspective on the Inauguration Script

Submission of the President s Budget in Transition Years

ELECTING THE PRESIDENT:

The White House and Press Timeline Compiled January 2017

Qualifications for Presidency

Presidential Potpourri

Vermont Presidential Primaries

Your web browser (Safari 7) is out of date. For more security, comfort and the best experience on this site: Update your browser Ignore

Norman H. and Charlotte Strouse collection of letters of the presidents, FLP.RBD.PRESIDENTS

2. A bitter battle between Theodore Roosevelt and his successor, William H. Taft, led to.

The Making of America s Presidency Our Presidents in America s History Series

1. George Washington : Father of the Country, Rev War leader, Whiskey Rebellion, Supreme Court Chief Justice John Jay, Mount Vernon 2.

Roosevelt sought a Square Deal for capital, labor, and the public. The Three C s Corporate control Consumer protection Conservation

Governors (and Generals) Rule Christopher DeMuth

Executive Parity: How the Structure of Executive Branches at the City, State, and Federal Level Impacts Presidents and Presidential Candidates.

T H E U. S. G OV E R N M E N T

FEDERAL GOVERNMENT GOVT President & Domestic Policy October 11, Dr. Michael Sullivan. MoWe 5:30 6:50 MoWe 7 8:30

Teaching With Primary Sources. Jerry Perry, State Bar of Texas

History of Our Parties

Presidents of the United States. Either Fought undeclared naval war with France

US History I

Presidential Inauguration January 20, 2009

By George! In one day. Why is George Washington remembered as the Father of Our Country? Materials. Overview

TEACHER S GUIDE Educational Video Group, Inc.

Transcription:

mith College Computer Science Lecture Notes Week 11 Everyday Python CSC111 Spring 2015 Dominique Thiébaut dthiebaut@smith.edu

Lists of Lists (Chapter 11 Designing with Lists and Classes)

Two Types of Lists Useful List Operations Two Approaches to Filtering Data Examples

Two Types of Lists somelist1 = [ 1, hello, 6.5 ] somelist2 = ( 1, hello, 6.5 )

Two Types of Lists somelist1 = [ 1, hello, 6.5 ] somelist2 = ( 1, hello, 6.5 ) mutable immutable

Notation Tuple

Two Types of Lists Useful List Operations Two Approaches to Filtering Data Examples

Useful List Operations

Useful List Operations Sorting Tuples

Two Types of Lists Useful List Operations Two Approaches to Filtering Data Examples

Two Types of Filtering Problems

The Problem at Hand Textual Info.

The Problem at Hand OPTION 1: We are only interested in the red information, and only the smaller or larger items Textual Info.

The Problem at Hand [ (,, ), (,, ), (,, ), (,, ) ] Textual Info. [ (,, ), (,, ), (,, ), (,, ) ]

The Problem at Hand [ (,, ), (,, ), (,, ), (,, ) ] SORT Textual Info. [ (,, ), (,, ), (,, ), (,, ) ]

The Problem at Hand OPTION 2: We are only interested in the lines that contain the red information Textual Info.

The Problem at Hand [ (,, ), (,, ), (,, ), (,, ) ] FILTER [ (,, ), (,, ) ] Textual Info.

Two Types of Lists Useful List Operations Two Approaches to Filtering Data Examples

Example 1

10 Rainiest Months In Cambridge, U.K.? http://cs.smith.edu/~dthiebaut/uktemperatures/

Example 2

Ammie@hampshire.edu Bessie@smith.edu Carylon@smith.edu Cheryll@smith.edu Cordelia@smith.edu Illa@smith.edu Lisbeth@smith.edu Mackenzie@smith.edu Maryellen@smith.edu Matha@smith.edu Patrica@hampshire.edu Sanjuana@smith.edu Sharie@smith.edu Sonya@smith.edu Yuko@smith.edu Cheryll@smith.edu Codi@smith.edu Cordelia@smith.edu Elenore@smith.edu Emelia@smith.edu Josie@smith.edu List of email addresses for students enrolled in several classes. Need a list of all Smith students without duplicates and a list of all 5-College students without duplicates

Example 3

U.S. Presidents text="""presidency,president, Took office,left office,party, Home State 1, George Washington, 30/04/1789, 4/03/1797, Independent, Virginia 2, John Adams, 4/03/1797, 4/03/1801, Federalist, Massachusetts 3, Thomas Jefferson, 4/03/1801, 4/03/1809, Democratic-Republican, Virginia 4, James Madison, 4/03/1809, 4/03/1817, Democratic-Republican, Virginia 5, James Monroe, 4/03/1817, 4/03/1825, Democratic-Republican, Virginia 6, John Quincy Adams, 4/03/1825, 4/03/1829, Democratic-Republican/National Republican, Massachusetts 7, Andrew Jackson, 4/03/1829, 4/03/1837, Democratic, Tennessee 8, Martin Van Buren, 4/03/1837, 4/03/1841, Democratic, New York 9, William Henry Harrison, 4/03/1841, 4/04/1841, Whig, Ohio 10, John Tyler, 4/04/1841, 4/03/1845, Whig, Virginia 11, James K. Polk, 4/03/1845, 4/03/1849, Democratic, Tennessee 12, Zachary Taylor, 4/03/1849, 9/07/1850, Whig, Louisiana 13, Millard Fillmore, 9/07/1850, 4/03/1853, Whig, New York 14, Franklin Pierce, 4/03/1853, 4/03/1857, Democratic, New Hampshire 15, James Buchanan, 4/03/1857, 4/03/1861, Democratic, Pennsylvania 16, Abraham Lincoln, 4/03/1861, 15/04/1865, Republican/National Union, Illinois 17, Andrew Johnson, 15/04/1865, 4/03/1869, Democratic/National Union, Tennessee 18, Ulysses S. Grant, 4/03/1869, 4/03/1877, Republican, Ohio 19, Rutherford B. Hayes, 4/03/1877, 4/03/1881, Republican, Ohio 20, James A. Garfield, 4/03/1881, 19/09/1881, Republican, Ohio 21, Chester A. Arthur, 19/09/1881, 4/03/1885, Republican, New York 22, Grover Cleveland, 4/03/1885, 4/03/1889, Democratic, New York 23, Benjamin Harrison, 4/03/1889, 4/03/1893, Republican, Indiana 24, Grover Cleveland, 4/03/1893, 4/03/1897, Democratic, New York 25, William McKinley, 4/03/1897, 14/9/1901, Republican, Ohio 26, Theodore Roosevelt, 14/9/1901, 4/3/1909, Republican, New York 27, William Howard Taft, 4/3/1909, 4/03/1913, Republican, Ohio 28, Woodrow Wilson, 4/03/1913, 4/03/1921, Democratic, New Jersey 29, Warren G. Harding, 4/03/1921, 2/8/1923, Republican, Ohio 30, Calvin Coolidge, 2/8/1923, 4/03/1929, Republican, Massachusetts 31, Herbert Hoover, 4/03/1929, 4/03/1933, Republican, Iowa 32, Franklin D. Roosevelt, 4/03/1933, 12/4/1945, Democratic, New York 33, Harry S. Truman, 12/4/1945, 20/01/1953, Democratic, Missouri 34, Dwight D. Eisenhower, 20/01/1953, 20/01/1961, Republican, Texas 35, John F. Kennedy, 20/01/1961, 22/11/1963, Democratic, Massachusetts 36, Lyndon B. Johnson, 22/11/1963, 20/1/1969, Democratic, Texas 37, Richard Nixon, 20/1/1969, 9/8/1974, Republican, California 38, Gerald Ford, 9/8/1974, 20/01/1977, Republican, Michigan 39, Jimmy Carter, 20/01/1977, 20/01/1981, Democratic, Georgia 40, Ronald Reagan, 20/01/1981, 20/01/1989, Republican, California 41, George H. W. Bush, 20/01/1989, 20/01/1993, Republican, Texas 42, Bill Clinton, 20/01/1993, 20/01/2001, Democratic, Arkansas 43, George W. Bush, 20/01/2001, 20/01/2009, Republican, Texas"""

We stopped here last time

Class Inheritance

Class Inheritance

The Idea

Car class - constructor - draw - move - undraw - changecolor - etc

Car class - constructor - draw - move - undraw - etc Wanted with same features

Car class - constructor - draw - move - undraw - changecolor - etc Wanted with same features Wanted with same features

We could write complete new classes for the two new car shapes But instead, we can save code, save time, save debugging aggravation, by reusing the original car class.

We could write complete new classes for the two new car shapes But instead, we can save code, save time, save debugging aggravation, by reusing the original Car class. We will derive new classes from the Car class. The new classes will be derived from it, and will inherit all the member variables and methods. The Car class will become the super class.

Another Way to Look at Inheritance valu Class

Another Way to Look at Inheritance valu value2 Super Class Derived Class

Coding Example

The Super Class

The Derived Class

Creating a Truck Derived from a Car

Two Different Syntaxes def draw( self, win ): super().draw( win ) self.top.draw( win ) def draw( self, win ): Car.draw( self, win ) self.top.draw( win )

Two Different Syntaxes def draw( self, win ): super().draw( win ) self.top.draw( win ) def draw( self, win ): Car.draw( self, win ) self.top.draw( win ) Cleaner code

Graphics Libraries Are Built on Inheritance: Hierarchy of Classes

Coding Exercise Create an Animal class (name, dob, vaccinated, tattooed) Create a sub-class of Animal: Cow (milkproduction) Create Dog a sub-class of Animal (trained, hospital, seeingdog, rescue)