CSI Lab 13. Tuesday, April 15th

Similar documents
Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Search Trees Due: Start of your next lab session

Pattern Maker Lab. 1 Preliminaries. 1.1 Writing a Python program

CS 1110, LAB 12: SEQUENCE ALGORITHMS First Name: Last Name: NetID:

Background: This programming assignment focuses on implementation and usage of a graph data structure.

Background: This programming assignment focuses on implementation and usage of a graph data structure.

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

CS 1110, LAB 10: ASSERTIONS AND WHILE-LOOPS 1. Preliminaries

CS 112: Intro to Comp Prog

CSCI 200 Lab 3 Using and implementing sets

Top Down Breaking a Problem Down

CS106 Lab 1: Getting started with Python, Linux, and Canopy. A. Using the interpreter as a fancy calculator

CS 1110, LAB 1: PYTHON EXPRESSIONS.

Starting. Read: Chapter 1, Appendix B from textbook.

CS Homework 11 p. 1. CS Homework 11

CSCI 3155: Lab Assignment 6

CPSC 217 Assignment 4

Grande Prairie Regional College

Credit: The lecture slides are created based on previous lecture slides by Dan Zingaro.

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

Lecture 1 Getting Started with SAS

Lab Assignment #1: Introduction to Creo ME 170

Assignment 1. Due Tuesday October 11 at 11pm. No late assignments will be accepted. What to do

CS Lecture 19: Loop invariants

CS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:

Your step-by-step instructions to getting started on ipage. Includes:

CpSc 1111 Lab 9 2-D Arrays

CSC 443: Web Programming

BIS1523 Homework Assignments 2.1

EECE.2160: ECE Application Programming

CSCB58 - Lab 0. Intro to The Lab & The DE2 Board. Prelab /4 Part I (in-lab) /1 Part II (in-lab) /1

PIC 10B Lecture 1 Winter 2014 Homework Assignment #2

15-110: Principles of Computing, Spring 2018

Cmpt 101 Lab 1 - Outline

CSCI 204 Introduction to Computer Science II

PIC 10B Lecture 1 Winter 2014 Homework Assignment #3

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Online Bidding System

User Guide. for placing your own Interlibrary Loan Requests. Place Interlibrary Loan requests using the INFO end user interface.

CS1110 Lab 1 (Jan 27-28, 2015)

Data Structures. Subodh Kumar. Dept of Computer Sc. & Engg. IIT Delhi. Bharti 422)

PA101 Learning the Ropes

During this screencast, we ll show you how Brown University students can use registration overrides to register for courses.

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

Part 2: Programming Questions

CMSC 201 Spring 2017 Lab 01 Hello World

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab.

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Project No. 2: Process Scheduling in Linux Submission due: April 12, 2013, 11:59pm

Implementing nml: Hindley-Milner Type Inference

CS 051 Homework Laboratory #2

a b c d a b c d e 5 e 7

CS Homework 10 p. 1. CS Homework 10

ASSIGNMENT 5 Objects, Files, and More Garage Management

CSCI 3155: Lab Assignment 6

The source code for this lab must be submitted in a file named lab4.py. The source code file must contain a file header formatted as in previous labs.

CSIS 10B Lab 2 Bags and Stacks

Computer Science II CSci 1200 Sections 1-4,6 Week 6, Friday Class October 5, 2001 Linked Lists, Part 2

CS 1110, LAB 2: FUNCTIONS AND ASSIGNMENTS

15-110: Principles of Computing, Spring 2018

Lab 3. A Multi-Message Reader

Submitting XML and Excel. Cost Reports

CSE 21 Spring 2016 Homework 5. Instructions

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

EECS2031 Winter Software Tools. Assignment 1 (15%): Shell Programming

Screen Shot User Guide. Schools

CSI Lab 02. Tuesday, January 21st

************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE

EE355 Lab 5 - The Files Are *In* the Computer

Programming Languages ML Programming Project Due 9/28/2001, 5:00 p.m.

CS450 - Database Concepts Fall 2015

In-class activities: Sep 25, 2017

Binary Relations Part One

Final Project Option #1 Restaurant Simulation

15-110: Principles of Computing, Spring 2018

CMSC 201 Spring 2017 Lab 05 Lists

CSCI 447 Operating Systems Filip Jagodzinski

Breadth-First. Graphs in Python

Lecture 1. Course Overview, Python Basics

Lab - 8 Awk Programming

Today (1) N64 Controller (Project Checkpoint#1) Today (2) Administrative Info (1)

CS 1110, Spring 2018: Prelim 1 study guide Prepared Tuesday March 6, 2018

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

Department of Computer Science. COS 122 Operating Systems. Practical 3. Due: 22:00 PM

Homework Assignment 3

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.

CSE100 Principles of Programming with C++

Submitting Assignments

Lecture 1. Course Overview, Python Basics

Basic Web Application Development Spring credit hour Student Taught (Satisfactory/Unsatisfactory)

Final Project. This assignment demonstrates your understanding of the concepts from the CMIS 141 class.

CS150 - Assignment 5 Data For Everyone Due: Wednesday Oct. 16, at the beginning of class

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

Rubrics. Creating a Rubric

CMPSCI 119 LAB #1 Bar Graphs Professor William T. Verts

1. Go to and then click on the Bookstore link. Select Faculty Adoptions.

PERSONAL COMPUTING WEEBLY CLASS PROJECT

CS 1510: Intro to Computing - Fall 2017 Assignment 8: Tracking the Greats of the NBA

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project

Transcription:

CSI Lab 13 Tuesday, April 15th Video link for hints as you work on this lab: Lab 13 Hints Goal: Continue your practice writing functions. Write some code that uses a dictionary. Write some code that uses a set. Part 0: Let's Warm Up With Sets To complete the following lab, we will need to be using code that implements a set. Recall that a set is a collection of objects of potentially different types (like a list), where no two elements can be identical (not like a list). Open your book or the presentation slides from session 31 and answer the following questions: [Q1] How do we create a new, empty set? (In other words, what is the set constructor?) [Q2] What happens if you try to store duplicate elements in a set? [Q3] What does the following line do? for element in myset

[Q4] How do we add something to a set? [Q5] Open up IDLE, and type the following at the interpreter prompt: >>> myset = set() >>> myset2 = set() Please type the following commands and write down the output: Command Output print(myset) myset.add("bacon") print(myset) myset2.add("cheddar") print(myset2) myset.union(myset2) myset myset2 myset.add("cheddar") print(myset) myset.intersection(myset2) myset & myset2 myset2.symmetric_difference(myset) myset2 ^ myset [Q6] Please briefly explain what the symmetric_difference, union, and intersection set methods are doing. Introduction Websites like IMDB (which stands for Internet Movie DataBase) maintain all sorts of info about movies, the actors etc. If you search for a movie on the website, a web page showing information about the movie is displayed. It also shows all the actors in it. If you click on the hypertext link for an actor, you are taken to the actor s web page and can find all the info about him/her. i.e. names of movies in which the actor has acted,

some other info. This assignment should give you some insight into the working of such websites. In order to complete this lab you need some basic movie/actor data. Rather than giving you a huge database like IMDB uses, you are provided with a relatively small data file - movies.txt The format of this file is very simple. Each line represents one actor and a partial listing of the movies he/she has acted in. The format of one line of this file is: Name of Actor, Movie1, Movie2, Movie3... BUT WAIT!!! Read carefully about BOTH activities before you begin anything. This assignment will be made much easier if, in addition to the two required functions, you also write several helper functions. There are common pieces to these two activities. Rather than cut and paste and duplicating the code, you should provide common code in helper methods and let the two methods use this helper code. The last point or two of credit for this lab will be based on using good helper methods and not duplicating code. Before you begin, please create a new Python file called lab13.py and write the traditional comments at the top (file, author(s), and description). In addition, copy the following function into lab13.py where you replace my name with your name(s): Activity A : Analyzing two movies Your first task is to write a function called comparetwomovies() that is given two string parameters - assumed to be two unique titles of movies in our database

will print an error message and stop if either of the movies is not in our database will print a well formatted message about all of the actors in the two movies (A union B. Represented as A B). will print a well formatted message about all of the common actors in the two movies (A intersection B. Represented as A&B) will print a well formatted message about all of the actors who are in one movie, but not both (A symmetric_difference B. Represented as A^B which is the same as (A B) - (A&B) Recall from our discussions about Sets that the three main features described above can be illustrated as follows: How do I do that??? What is an appropriate data structure for this assignment? Movie names are unique and our aim is to find the actors in the movies subject to some criteria (&, or ^ ). In a dictionary, the keys are unique. So, that would make a good choice in this case. Using the movies.txt file, create a dictionary with movie names as keys and a SET of actors as values. A list could also be used instead of a set here, but then you would have to implement the union, intersection and other set operations all by yourself (If you want, you can try that! ).

Therefore, the High Level Algorithm for this method looks like this: 1. Read in the lines from the movies.txt file. 2. For each line: 1. Separate out the actor and his movies. 2. For each movie listed: a) If the movie name has not already been entered into the dictionary, add it as a key, and store the name of the actor as a value. b) If the movie name exists in the dictionary, add the actors name to the set of actors.i.e. to the value in the dictionary. 3. The dictionary is now ready. 4. Process the input to the function. 1. Are both of the inputs keys in your dictionary? a) If not, then print an appropriate error message and quit. b) If so, perform the three "searches" and print their results. While not required, I suggest that you write a small testing suite to test your code and demo this for one of the instructors before moving on. Here is a good test: Use movies: Sleeper and Troy

Union of the two movies will be: Brad Pitt, Dustin Hoffman, Kevin Bacon, Diane Kruger Intersection of the two movies will be: Brad Pitt Symmetric Difference of the two movies will be: Dustin Hoffman, Diane Kruger, Kevin Bacon Activity B : Finding one actor's co-actors Your next task is to write a function called coactors() that is given a single string parameter - assumed to be the name of an actor in our database will print a well formatted message about all of that actor's co-actors. That is, print a message containing all of the actors who appeared in a movie with the first actor. if the original actor is not in our database than a well formatted message indicating this should be printed. This activity starts the same way as Activity A - by building a dictionary/database of movies and actors. The challenge with this activity is discovering how to search that database for a particular actor and use the results of that search to solve this problem. Again, while not required, I suggest that you write a small testing suite to test your code and demo this for one of the instructors before moving on. Getting Credit for this assignment This week I will again ask you to submit your code for electronic grading, using the elearning submission system. Follow the directions on the system to select the appropriate course and assignment and submit lab13.py If you worked with a partner, make sure that both you and your partner's names are in the comment header at the top of the file and in the printname() function.