Problem 1
Import module math, and use its functions to complete the following exercises: a) Write a single expression that rounds the value of -4.3 and then takes the absolute value of that result. b) Write an expression that takes the ceiling of sine of 34.5
Problem 2
In the following exercises, you will work with Python鈥檚 calendar module: a) Visit the Python documentation website at http://docs.python. org/modindex.html, and look at the documentation on the calendar module. b) Import the calendar module. c) Read the description of the function isLeap. Use isLeap to determine the next leap year. d) Find and use a function in module calendar to determine how many leap years there will be between the years 2000 and 2050, inclusive. e) Find and use a function in module calendar to determine which day of the week July 29, 2016 will be
Problem 3
Using string methods, write expressions that do the following: a) Capitalize 鈥檅oolean鈥. b) Find the first occurrence of 鈥2鈥 in 鈥機02 H20鈥. c) Find the second occurrence of "2" in 鈥機02 H20鈥. d) Determine whether 鈥橞oolean鈥 begins with a lowercase. e) Convert "MoNDaY" to lowercase letters and then capitalize the result. f) Remove the leading whitespace from " Monday".
Problem 5
Why do you think the media module mentioned in Section 4.3, Objects and Methods, on page 60 isn鈥檛 part of the standard Python library? How do you think Python鈥檚 developers decide what should be in the standard library and what shouldn鈥檛? If you need something that isn鈥檛 in the standard library, where and how can you find it?
Problem 7
Write a program that allows the user to choose a file, sets the red value of each pixel in the picture to 0, and shows the picture.
Problem 9
Write a program that allows the user to pick a file and makes it grayscale; it should calculate the average of red, green, and blue values of each pixel and then set the red, green, and blue values to that average.
Problem 11
Media outlets such as newspapers and TV stations sometimes 鈥渆nhance鈥 photographs by recoloring them or digitally combine pictures of two people to make them appear together. Do you think they should be allowed to use only unmodified images? Given that almost all pictures and TV footage are now digital and have to be processed somehow for display, what would that rule actually mean in practice?