< Back

Lab 15: Compound Images


Practice Problem 1

Write a function multiply_letters(a_phrase, number_of_times), which takes a string and an integer as a parameter. Your function should accumulate the characters from a_phrase, number_of_times times.

Example

>>> multiply_letters("INQ 241A", 2)
IINNQQ  224411AA
>>> multiply_letters("INQ 241A", 3)
IIINNNQQQ   222444111AAA

Hint


Practice Problem 2

Write a function sum_integers(maximum_integer), which takes an integer as a parameter. This function should print the sum of all of the numbers starting at 0, up to but not including maximum_integer.

Example

>>> sum_integers(10)
45
>>> sum_integers(5)
10

Hint


Green Screen

In a file called green_screen.py, write a function called green_screen(foreground_picture, background_picture). This function should take 2 parameters: the picture you are going replace the green in, and the picture you are going to fetch the background pixels from. Your function should display a picture where all of the green pixels from foreground_picture with the corresponding pixel from background_picture.

Example

Parameter Images After

Hint