www.umbc.edu
CMSC201 Computer Science I for Majors
Lecture 15 – Program Design
- Prof. Katherine Gibson
Based on slides from the book author, and previous iterations of the course
CMSC201 Computer Science I for Majors Lecture 15 Program Design - - PowerPoint PPT Presentation
CMSC201 Computer Science I for Majors Lecture 15 Program Design Prof. Katherine Gibson Based on slides from the book author, and previous iterations of the course www.umbc.edu Last Class We Covered Functions Returning values
www.umbc.edu
Based on slides from the book author, and previous iterations of the course
www.umbc.edu
2
www.umbc.edu
www.umbc.edu
4
www.umbc.edu
www.umbc.edu
6
www.umbc.edu
7
www.umbc.edu
8
www.umbc.edu
def nS(p, c): l = len(p) if (l >= 4): c += 1 print(p) if (l >= 9): return p, c # FUNCTION CONTINUES...
9
www.umbc.edu
def nS(p, c): l = len(p) if (l >= 4): c += 1 print(p) if (l >= 9): return p, c # FUNCTION CONTINUES...
10
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= 4): count += 1 print(password) if (length >= 9): return password, count # FUNCTION CONTINUES...
11
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= 4): count += 1 print(password) if (length >= 9): return password, count # FUNCTION CONTINUES...
12
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= MIN_LENGTH): count += 1 print(password) if (length >= MAX_LENGTH): return password, count # FUNCTION CONTINUES...
13
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= MIN_LENGTH): count += 1 print(password) if (length >= MAX_LENGTH): return password, count # FUNCTION CONTINUES...
14
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= MIN_LENGTH): count += 1 print(password) if (length >= MAX_LENGTH): return password, count # FUNCTION CONTINUES...
15
www.umbc.edu
def nextState(password, count): length = len(password) if (length >= MIN_LENGTH): count += 1 print(password) if (length >= MAX_LENGTH): return password, count # FUNCTION CONTINUES...
16
www.umbc.edu
def nextState(password, count): length = len(password) # if long enough, count as a password if (length >= MIN_LENGTH): count += 1 print(password) # if max length, don't do any more if (length >= MAX_LENGTH): return password, count # FUNCTION CONTINUES...
17
www.umbc.edu
18
www.umbc.edu
19
www.umbc.edu
# check if car fits customer criteria if color == "black" and int(numDoors) > 2 \ and int(price) < 27000:
20
www.umbc.edu
# iterate over the list for item in myList:
# initialize the loop variable choice = 1 # loop until user chooses 0 while choice != 0
21
www.umbc.edu
www.umbc.edu
23
www.umbc.edu
24
Bad: def makeGrid(): temp = [] for i in range(0, 10): temp.append([0] * 10) return temp Good: def makeGrid(): temp = [] for i in range(0, GRID_SIZE): temp.append([0] * GRID_SIZE) return temp
www.umbc.edu
25
www.umbc.edu
www.umbc.edu
27
www.umbc.edu
28
www.umbc.edu
29
www.umbc.edu
www.umbc.edu
31
www.umbc.edu
32
www.umbc.edu
33
Big Idea
www.umbc.edu
34
Big Idea Part 1 Part 2 Part 3
www.umbc.edu
35
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B
www.umbc.edu
36
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B Part 2.B.1 Part 2.B.2
www.umbc.edu
37
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B Part 2.B.1 Part 2.B.2
www.umbc.edu
38
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B Part 2.B.1 Part 2.B.2
www.umbc.edu
39
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B Part 2.B.1 Part 2.B.2
www.umbc.edu
40
www.umbc.edu
www.umbc.edu
42
Big Idea Part 1 Part 2 Part 3 Part 2.A Part 2.B Part 2.C Part 3.A Part 3.B Part 2.B.1 Part 2.B.2
www.umbc.edu
43
www.umbc.edu
44
www.umbc.edu
45
www.umbc.edu
www.umbc.edu
47
www.umbc.edu
48
www.umbc.edu
49
www.umbc.edu
www.umbc.edu
51
www.umbc.edu
52
www.umbc.edu
53
www.umbc.edu
54
www.umbc.edu
55
www.umbc.edu
56
www.umbc.edu
57
www.umbc.edu
58
www.umbc.edu
www.umbc.edu
60