Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python Practice !!!.

Similar presentations


Presentation on theme: "Python Practice !!!."— Presentation transcript:

1 Python Practice !!!

2 Easy Picture Function # Turn all mostly-red pixels blue ("mostly-red" means within a distance of 140 of red) # Hints: use “distance”, “getColor”, “setColor” def redToBlue (pic): # add 3 more lines

3 Medium Picture Function
# turn bottom-right corner of a picture (100x100 pixels) white # Hints: use “getWidth”, “getHeight”, “getPixelAt”, “setColor” def whiteCorner (pic): # add 4 more lines

4 Easy “Miscellaneous” Function
# Count from 0 to 100 by 5s def countAndPrint (): # 2 more lines

5 Conversion Practice Write a function that displays in the command area (but does not return) the letter grade corresponding to a number grade (90 and up = A, etc.; no + or – grades). Write code that calls your function two times with grades 99 and 71.

6 Picture size practice Write a function to return the number of pixels in “pic”

7 Is a picture “big”? Write a function to return “true” if the picture is “big” (has over 90,000 pixels) (use the function you wrote on the previous slide)

8 Mystery Function # What do I do? def mystery (pic): for x in range (30,70): for y in range (0, 30): px1 = getPixel (pic, x, y) copyColor = getColor (px1) px2 = getPixel (pic, x, y+30) setColor (px2, copyColor)

9 # Code to turn the bottom half of a picture red

10 Generalize the previous function to allow it to change the bottom half of a picture to any color, not just red. E.g., we want to be able to type the following in the command area: bottomHalfRed3 (myPic, green) bottomHalfRed3 (yourPic, blue)


Download ppt "Python Practice !!!."

Similar presentations


Ads by Google