当循环在杰斯?

2024-07-04 07:43:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我是初学者,所以要友善

尝试更改此代码以包含while循环或修改它使用all while循环

谁能帮忙吗

def shrink():
 picture = makePicture(pickAFile())
 newPicture = makeEmptyPicture(getWidth(picture) /2, getHeight(picture) /2)
#time for our shrinking ray gun to work
 while x in range(getWidth(picture)):
  while y in range(getHeight(picture)):
   originalPixel = getPixel(picture, x, y)
   color = getColor(originalPixel)
   newPixel = getPixel(newPicture, x / 2, y / 2)
   setColor(newPixel, color)
 show(picture)
#Show and tell 
 show(newPicture) 

Tags: 代码inshowrangeallcolorpicture初学者

热门问题