Download presentation
Presentation is loading. Please wait.
1
CS 102 Computers In Context (Multimedia) 02 / 06 / 2009 Instructor: Michael Eckmann
2
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Today’s Topics Questions/comments? Let's read over the hw I assigned Review of reading pages 39-60 All the JES image functions covered in those pages Write a few more functions
3
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Calling functions What do we need to know to be able to call a function that already exists correctly?
4
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Some JES image functions makePicture getWidth, getHeight getPixel getPixels getX, getY getRed, getBlue, getGreen setRed, setBlue, setGreen distance getColor, setColor, makeColor pickAColor makeLighter, makeDarker writePictureTo show
5
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Try these Let's look at my solution to this: greetWrite a function named greet that takes in someone's name and displays a greeting to that person. For example if I call greet like this: greet('Mike') –It should display Hello, Mike, nice to see you.
6
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Try these displayWrite a function named display that displays an image, given a file name as a parameter. display('boat.jpg') –It should display the image boat.jpg noRedWrite a function named noRed that alters an image so that it has 0 for the red channel of each pixel. It should take in a picture object as a parameter and alter that picture. pic = makePicture('boat.jpg') noRed(pic) show(pic) # display the boat image after noRed set all reds to 0
7
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 docstrings Docstrings are special comments describing the function, module, class or method being defined. Example: def factorial(num): """ factorial computes the factorial of the number num. num! = num * (num-1) * (num-2) *... * 1 returns an integer, the factorial of num """ fact = 1 while (num > 1): fact = fact * num num -= 1 return fact
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.