# Lecture 7

1. ### Black Box and Glass Box Testing

With the below implementation, is the test set “n = 4 | n = -4 | n = 5” path complete?

def is_even(n):


Yes  check
No  close

With the above implementation, which value for n is incorrectly labeled by is_even?

n is very large (and positive)  close
n is very small (and negative)  close
n is 0  check

1. ### Errors

Below is a piece of code and an error shown when running it. What is the problem?

L = 3


You are not allowed to name an integer with the variable name L  close
range is not allowed to have an expression inside its parentheses  close
You are not allowed to call len on an integer  check
You are not allowed to print the loop variable i  close

2. ### Exceptions

If the user enters “twenty” in the code below what does the program do?

try:


prints "You've gone through 25.0 % of your life!"  close
prints "Oops, must enter a number."  check

If the user enters “0” in the code above what does the program do?

prints "You've gone through 0.0 % of your life!"  check
prints "Division by zero."  close

#### Learning Resource Types

assignment Problem Sets
notes Lecture Notes
theaters Lecture Videos
assignment_turned_in Programming Assignments with Examples