Processing math: 0%
< Back

Lab 18: Compound Images


Practice Problem 1

Write a function called print_words(text), which prints the each word from the text on its own line. Assume each word is separated by exactly one space.

Example

>>> print_words("INQ241A")
INQ241A
>>> count_words("INQ 241A")
INQ 241A
>>> count_words("How much wood could a woodchuck chuck if a woodchuck could chuck wood")
How
much
wood
could
a
woodchuck
chuck
if
a
woodchuck
could
chuck
wood

Hint


Practice Problem 2

A power tower is a number x raised to the x power x times. Mathematically, it looks like:

x^{x^{x^{{\cdot^{\cdot^{\cdot^{x}}}}}}}

Write a function called power_tower(x), which prints the tower power for the integer x.

Example

>>> power_tower(1)
1
>>> power_tower(2)
4
>>> power_tower(3)
19683

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