Ask your own question, for FREE!
Computer Science 15 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
AsianPanda08: What should i eat for dinner tonight? I can't choose
47 minutes ago 51 Replies 2 Medals
Nina001: Trying 2 figure out what is the square root of 8746685
1 hour ago 23 Replies 2 Medals
SnowyBreaks: Is it bad to lose 3.8 pounds in less than 2 days?
46 minutes ago 42 Replies 0 Medals
kaelynw: tried a lil smt, the arm is off but i like the other stuff
4 hours ago 8 Replies 2 Medals
laylasnii13: Who wanna write or make a song with me???
4 hours ago 8 Replies 0 Medals
kaelynw: art igg
12 hours ago 13 Replies 2 Medals
XShawtyX: Art
1 day ago 6 Replies 0 Medals
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!