Presentation is loading. Please wait.

Presentation is loading. Please wait.

CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151.

Similar presentations


Presentation on theme: "CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151."— Presentation transcript:

1 CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151

2 Announcements Reading and RQ 12 for next time Assignment 5 due Thursday APT 5 due today, APT 6 due March 17 compsci101 spring152

3 Set Operations from pictures bit.ly/101S15-0303-01 Question: Which operation does the red represent? E) A) B) C) D) compsci101 spring153

4 Problems – snarf setExample.py Given a list of strings that have the name of a course (one word), followed by last names of people in the course: –Convert list into lists of strings of names for each course –Find total number of people taking any course –Find number of people taking just one course ["econ101 Abroms Curtson Williams Smith”, "history230 Black Wrigley Smith”, … ] compsci101 spring154

5 Data for example [“compsci101 Smith Ye Li Lin Abroms Black“, “math101 Green Wei Lin Williams DeLong Noell, Ye, Smith”, “econ101 Abroms Curtson Williams Smith”, “french1 Wills Wrigley Olson Lee”, "history230 Black Wrigley Smith” ] compsci101 spring155

6 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell Set Picture of Data compsci101 spring156

7 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell People in CompSci 101 compsci101 spring157

8 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell People Taking both Math And CompSci Intersection compsci101 spring158

9 Part 1 – processList bit.ly/101S15-0303-02 Given a list of strings that have the name of a course (one word), followed by last names of people in the course: –Convert list into lists of strings of names for each course ["econ101 Abroms Curtson Williams Smith", "history230 Black Wrigley Smith", … ] [[‘Abroms’, ‘Curtson’, ‘Williams’, ‘Smith’], [‘Black’, ‘Wrigley’, ‘Smith’, …]] compsci101 spring159

10 Part 2 – peopleTakingCourses bit.ly/S15-0303-03 Given a list of lists of names, each list represents the people in one course: –Find total number of people taking any course Small Example [[‘Abroms’, ‘Curtson’, ‘Williams’, ‘Smith’], [‘Black’, ‘Wrigley’, ‘Smith’]] Answer is 6 unique names compsci101 spring1510

11 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell People taking Courses - Union Total Number Is 17 unique names compsci101 spring1511

12 Next, find the number of people taking just one course compsci101 spring1512

13 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell Union all sets But French1 compsci101 spring1513

14 To solve this problem First let’s write a helper function compsci101 spring1514

15 Part 3 – unionAllSetsButMe bit.ly/101S15-0303-04 Given example, a list of sets of strings, and the index of one of the sets, return the union of all the sets but that one example = [set(["a", "b", "c"]), set(["b", "c", "d", "g"]), set(["e", "d", "a"])] unionAllSetsButMe(example,1) is set(["a", "b", "c", "e", "d" ]) 15

16 Part 4 – peopleTakingOnlyOneCourse bit.ly/101S15-0303-05 Given a list of lists of strings of names representing people from courses –Find number of people taking just one course [[‘Abroms’, ‘Curtson’, ‘Williams’, ‘Smith’], [‘Black’, ‘Wrigley’, ‘Smith’, ‘Abroms’]] 4 compsci101 spring1516

17 Smith COMPSCI101 MATH101 ECON101 HISTORY230 FRENCH1 Green Ye Li Black LeeOlson Wills Wrigley Abroms Williams Curtson Lin Wei Yavatkar Delong Noell People taking Only one course compsci101 spring1517

18 APT - UniqueZoo How do you solve this problem? How is it similar to the problem we just solved compsci101 spring1518

19 Example Data for UniqueZoo ["zebra bear fox elephant","bear crocodile fox", "rhino elephant crocodile kangaroo", "elephant bear"] zebra elephant fox bear kangaroo rhino crocodile compsci101 spring1519

20 UniqueZoo – two zoos have unique animals zebra elephant fox bear kangaroo rhino crocodile compsci101 spring1520


Download ppt "CompSci 101 Introduction to Computer Science March 3, 2015 Prof. Rodger compsci101 spring151."

Similar presentations


Ads by Google