Processing math: 100%
< Back

Lab 17: Compound Images


Practice Problem 1

Write a function called count_words(text), which prints the number of words contained in the text. Assume each word is separated by exactly one space.

Example

>>> count_words("INQ241A")
1
>>> count_words("INQ 241A")
2
>>> count_words("Digital Media is the worst class I've ever taken. Coding is literally impossible")
13

Hint


Practice Problem 2

Write a function called perfect_power(x). This function should return the result of xx.

Example

>>> perfect_power(1)
1
>>> perfect_power(2)
4
>>> perfect_power(3)
27
>>> perfect_power(5)
3125

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