Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (he66666):

Help on python: If the function name is "widen", with the parameter "picture" and the return type being a picture, return a new picture that is twice as wide as the given picture. For each pixel (x, y) in the original picture, the pixels (2 * x, y) and (2 * x + 1, y) in the new picture should be set to the same color as it. Can someone please help me? I cant seem to do this. (btw, we cannot use the PIL)

OpenStudy (rsmith6559):

xy coordinates suggest a list of lists as the data structure. For all the color datum in the horizontal, just add it twice to the horizontal of a new list of lists.

OpenStudy (he66666):

Yes I understand that but I don't get how you would set the function. I'm a beginner at Python so I don't know how to set the function properly. I also don't get why in the question 1 is added to 2*x in the x-coordinate?

OpenStudy (rsmith6559):

TBH, ( 2 * x, y ) suggests to me that the image becomes two images side by side. If you just want to distort the image to be twice as wide, reading ( x, y ) from the input picture and writing x to ( x, y ) and ( x +1, y ) in a new image ( to be returned from the function ) will make it twice as wide. The Python syntax for a function would be: def widen( inputPicture ): # make the new picture return( outputPicture ) And would be called something like: fatPicture = widen( thinPicture ) I don't know what else to say without writing the code for you without a more specific question.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
5 hours ago 2 Replies 0 Medals
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
5 hours ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
16 hours ago 27 Replies 3 Medals
kaelynw: art igg
15 hours ago 14 Replies 2 Medals
XShawtyX: Art
3 days ago 6 Replies 0 Medals
Nina001: teach me how to draw or just tell me the basics
3 days ago 2 Replies 1 Medal
XShawtyX: We doing another drawing gimme ideas to add to this
3 days ago 9 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!