Download presentation
Presentation is loading. Please wait.
1
FUNCTION 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 Sound Function # Shift all samples in a sound "up" by # Hints: use “getSamples”, “getSampleValue”, “setSampleValue” def upShift (sound): # 3 more lines
5
Medium Sound Function # Create a new sound that cuts the frequency of a sound in half (doubles its length so it sounds "lower") # Hints: use “getSamples”, “getSampleValue”, “setSampleValueAt” def halveFrequency (sound): target = targetIndex = for s in getSamples (sound): # 4 lines inside loop # 1 more line below here
6
Easy “Miscellaneous” Function
# Count from 0 to 100 by 5s def countAndPrint (): # 2 more lines
7
Medium “Miscellaneous” Problem
# Print a line of 10 hellos, a line of 9 hellos, ..., a line of 1 hello # Hints: use 2 “for” loops. The command print “hello”, # will keep the printing on the same line. The command print # will send printing to the next line def helloThere(): # 4 more lines, including the “for”s for i in range for j in range
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.