COMP 204
Debugging skills and Nested loops Mathieu Blanchette
1 / 12
COMP 204 Debugging skills and Nested loops Mathieu Blanchette 1 / - - PowerPoint PPT Presentation
COMP 204 Debugging skills and Nested loops Mathieu Blanchette 1 / 12 Quiz 7 password 2 / 12 Testing your program Once youve written a first draft of your program, you need to test it: Provide some input data, and verify manually that
1 / 12
2 / 12
◮ For the last question of assignment #1 (protein length): ◮ What if the gene sequence has no start codon? ◮ What if it has no in-frame stop codon? ◮ What if it has an out-of-frame stop codon?
3 / 12
4 / 12
1 w h i l e
2
3
4
5
6 7 # r e s t
5 / 12
6 / 12
1 import
2 3 e n t r y=”” 4 w h i l e
5
6
7
8
9
10 11
12
13
14
15
16
17
18
19
20
21 22
23
7 / 12
1 import
2 3 e n t r y=”” 4 w h i l e
5
6
7
8
9
10 11
12
13
14
15
16
17
18
19
20
21 22
23
7 / 12
◮ Use an inner loop to iterate through heights from 1.0 to 2.0 ◮ Calculate BMI from current values of weight and height, print 8 / 12
1 weight = 50 2 w h i l e
3
4
5
6
7
8
9 / 12
1 weight = 50 2 w h i l e
3
4
5
6
7
8
1 # What ’ s
2 weight = 50 3 h e i g h t = 1.6 # r e s e t
4 w h i l e
5
6
7
8
9
9 / 12
1 weight = 50 2 w h i l e
3
4
5
6
7
8
1 # What ’ s
2 weight = 50 3 h e i g h t = 1.6 # r e s e t
4 w h i l e
5
6
7
8
9
1 import
2 f o r
3 #
4
5
6
9 / 12
◮ Test each candidate by using a second loop that enumerates
◮ If never found a factor, then the number is prime. Print it. 10 / 12
1 import
2 maxNumber = i n t ( i n p u t ( ” Enter max .
3 4 candidatePrime = 2 5 w h i l e
6 7
8
9
10
11
12
13
14
15
16
17
18 19
20 21
22
23 24
11 / 12
1 # for −loop
2 import
3 maxNumber = i n t ( i n p u t ( ” Enter max .
4 5 candidatePrime = 2 6 7 f o r
8 9
10
11
12
13 14
15
16
17
18
12 / 12