< Back

Lab 12: Images


Practice Problem 1

Write a function list_letters(a_phrase), which takes a string as a parameter. Your function should list all of the characters out of a_phrase, each on their own line.

Example

>>> list_letters("INQ 241A")
I
N
Q

2
4
1
A
>>> list_letters("Trexler")
T
r
e
x
l
e
r

Hint


Practice Problem 2

Write a function list_integers(start, end), which takes two integers as parameters. This function should print all of the values that exist in the range specified.

Example

>>> list_integers(0, 10)
0
1
2
3
4
5
6
7
8
9
>>> list_integers(5, 10)
5
6
7
8
9
>>> list_integers(5, 15)
5
6
7
8
9
10
11
12
13
14

Hint


Lines

In a file called hair_color.py, write a function called change_hair_to_red(picture, hair_color). This function should takes two parameters: the picture you are going to modify, and the color of hair you wish to make red. This function should change any pixel that has a color "similar" to hair_color to straight red. Consider two colors "similar" if their "distance" is less than 50.

Example

Before After

Hint