计算机专外-Week1 exercises

Week 1 > Code Writing Exercises > Problems


Q1: Change the “print” code below so it produces the following output when run:
1 2 hello

print(1, 2,"hello");

Q2: Change the “print” code below so it produces the following output when run:

1
1 2
1 2 3

print(1);
print(1,2);
print(1,2,3);

Week 1 >Code Variables Exercises > Problems


Q1: Change just one line of the code below so it produces the following output when run.

xyz123
xyz123 xyz123
xyz123 xyz123 xyz123

x = "xyz123";
print(x);
print(x, x);
print(x, x, x);

Week 1 >Digital Image Exercises > Problems


Q1: How many colors can a single pixel show at one time?
1

Q2: In the RGB scheme, what are the RGB numbers to make pure white? Please type in the red, green, and blue numbers separated by spaces like this: 100 126 255
255 255 255

Q3: What are the RGB numbers to make bright yellow? (Please type in the red, green, and blue numbers separated by spaces like this: 100 126 255)
255 255 0


Week 1 > Image Code Exercises > Problems


Q1: Write code to set the pixel at (0, 0) to blue (i.e. blue value is 255, red and green are left at 0).

image = new SimpleImage("x.png");
image.setZoom(20);
pixel = image.getPixel(0, 0);
pixel.setRed(0);
pixel.setGreen(0);
pixel.setBlue(255);
print(image);

Q2: Write code to set the pixel at (0, 0) to be violet (i.e. red and blue both 255, green left at 0).

image = new SimpleImage("x.png");
image.setZoom(20);
pixel = image.getPixel(0, 0);
pixel.setRed(255);
pixel.setGreen(0);
pixel.setBlue(255);
print(image);

Q3: Write code to set the pixel at (1, 0) to be red

image = new SimpleImage("x.png");
image.setZoom(20);
pixel = image.getPixel(1, 0);
pixel.setRed(255);
print(image);
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值