# a9q1 - CS 116 Ru Wang r46wang 20319247 Assignment 9...

This preview shows pages 1–2. Sign up to view the full content.

## CS 116 Ru Wang r46wang 20319247 ## Assignment 9 Question 1 ## a meeting_time class definition ## month is string, day is string, and hr is an integer with range [8:20] class meeting_time: 'Fields: month, day, hr' ##For easier testing: A = meeting_time() A.month = 'Jan' A.day = 1 A.hr = 11 B = meeting_time() B.month = 'Feb' B.day = 2 B.hr = 12 C = meeting_time() C.month = 'Mar' C.day = 3 C.hr = 15 D = meeting_time() D.month = 'Apr' D.day = 4 D.hr = 17 E = meeting_time() E.month = 'May' E.day = 5 E.hr = 18 ## Part a ## afternoon: (listof meeting_time) -> (listof meeting_time [12<=hr<=17] ) ## purpose: this function consumes a list of meeting_time and produces a meeting_time list with each meetin_time if 12<=hr<=17. ## examples: ## afternoon([]) => [] ## afternoon ([A]) => [] ## afternoon ([E]) => [] ## afternoon ([A,B,C,D,E]) => [B, C, D] def afternoon(alom): return filter(lambda x: (x.hr >= 12 and x.hr <= 17), alom) ## Testings: ## empty case: print "part a Test 1" expect = [] ans = afternoon([])

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

a9q1 - CS 116 Ru Wang r46wang 20319247 Assignment 9...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online