To start this lab, download this zip file.

# Lab 9 - Scripts

## Pytest

From now on, we will provide you with the pytests we use to grade your labs and projects. These tests will provide insight on what errors are occurring in your code and how to fix them.

To install pytest, go to your terminal and run:

`conda activate cs110`

Then run:

`pip install byu-pytest-utils`

## What does this print?

Draw it out!

```
def divides_by_three(number):
return number % 3 == 0
def main(number):
if divides_by_three(number):
print('woot!')
else:
print('boo')
main(6)
main(7)
main(8)
main(9)
```

```
def under_ten(number):
return number % 10
def main(number):
number = under_ten(number)
number = number + (number // 2)
print(number)
main(7)
main(17)
main(32)
```

```
n = 0
while n < 4:
print(n)
n = n + 1
```

```
def increment_and_mod(n, mod):
return (n + 1) % mod
iteration = 0
n = 0
while iteration < 10:
iteration = iteration + 1
print(n)
n = increment_and_mod(n, 3)
```

```
def add(a, b):
return a + b
total = 0
n = 0
while n < 5:
total = add(total, n)
n = add(n, 1)
print(total)
```

```
def print_to_zero(n):
while n >= 0:
print(n)
n = n - 1
print_to_zero(3)
print_to_zero(4)
```

```
def is_even(number):
return number % 2 == 0
def print_smaller_evens(n):
while n >= 0:
n = n - 1
if is_even(n):
print(n)
print_smaller_evens(10)
```

```
start = 5
end = 10
n = start
while n < end:
print(n)
n = n + 1
```

```
def add_all(a, b, c, d):
result = a + b + c + d
print(add_all(1, 2, 3, 4))
```

## Activities

`odd_numbers.py`

You are provided with the script `odd_numbers.py`

; however, it isn’t working as desired.

The function `print_lower_odds(number)`

should print out all odd numbers less than number, from greatest to least, each number being prefixed by >> .

For example:

`print_lower_odds(10)`

Should print:

```
>> 9
>> 7
>> 5
>> 3
>> 1
```

Use the debugger to help you identify the problems and then fix them.

`oddities.py`

Write a function `print_oddities_up_to(number)`

that it prints all “oddities” less than `number`

from least to greatest.

In this case, a number is an “oddity” if it is not divisible by 2 or 3.

Write at least one additional function that determines whether a number is an oddity or not.

For example:

`print_oddities_up_to(8)`

Would print:

```
1
5
7
```

`math_practice.py`

Implement the functions found in math_practice.py following the instructions provided in the docstrings.

## Grading

Activity | Points |
---|---|

`odd_numbers.py` | 6 points |

`oddities.py` | 6 points |

`math_practice.py` | 3 points for each function |