Processing math: 100%
< Back

Lab 19: Images


Practice Problem 1

Write a function called convert_grade(numeric_grade), which takes an integer in the range (0,5). Your function should print the letter grade the user recieved, given the numeric grade:

Numeric Grade Letter Grade
0F
1D
2C
3B
4A

Example

>>> convert_grade(0)
F
>>> convert_grade(1)
D
>>> convert_grade(4)
A

Hint


Practice Problem 2

Write a function called print_factors(x), which prints all of the positive integer factors of x. An integer y is an integer factor of x if the remainder of xy is 0.

Example

>>> print_factors(1)
1
>>> print_factors(2)
1
2
>>> print_factors(4)
1
2
4

Hint


Blurred Images

In a file called blurred_images.py write a function called simple_blur(a_picture). This function should display a blurred version of the image parameter.

To blur an image, you simply average a pixels color value with the 4 pixels surrounding it.

Example

Before After

Note: This image has actually been blurred 4 times, to make it obvious what is happening. Your image will only be slightly fuzzy.

Hint