Homework 1

< CS101

Homework 1 gathers homeworks from code-1-introduction.html

count 7 : code-1-ex1 code-1-ex2 code-1-ex3 code-1-ex4 code-2-ex1 code-2-ex2 code-2-ex3

(code appears here)

Due 11:59pm ending monday Jan 23rd (oops, said 16th here originally). Details for turning in to follow on Thu.

Problem 1

Write code that prints the following with your name.

Hello, my name is Alice
Alice is in this class
Without a doubt Alice is working on this homework

Rather than mentioning your name directly, assign a variable to hold your name (i.e. name = ... ; ), then use that name variable within the print statements to insert your name. It should be possible to assign a different string to the variable, "Bob" or "Abby" or whatever, and then that name will appear in the printout when run.


Problem 2

Write code that changes the flowers.jpg as follows: for every pixel, set the red value to 0 and the green and blue values to 255. Print the resulting image.


Problem 3

This is a 10-20-30 puzzle. Write code to recover and print the original image from the image 10-20-30-2.png.


4. Iron Image Puzzle

I must say, I really like this code puzzle as a way of getting a computing principles. This is a puzzle. You are given an image of something famous. However the image has been messed up: the real data is in the red channel, however the red channel values have all been divided by 10, so they are too small by a factor of 10. The blue and green channels are just meaningless random values ("noise") added to obscure the real image. You must undo all these steps to recover the real image.


5. Copper Image Puzzle

This is an image puzzle -- an image of something famous is hidden in the image "copper-puzzle.png". The real image is in the blue and green channels, however the blue and green values have all been divided by 20, so the values are very small. The red channel is just noise added on top to obscure things. Undo these obscuring factors to recover the original image.


6. California State Flower

Change the code below to make all of the following changes to the "flowers.jp g" image and print the result.


Submission instructions: 1. On this page, click the button below to collect the code answers to all the questions as one block of text. Copy that text.
2. Now navigate to Coursework ---> Assignments --> Homework 1. There should be one question in Homework 1, where you will paste in the text of all your answers.
3. Submit the assignment in Coursework and you're done!

Retrieve Code

Retrieves locally stored exercise code for this page from the 'Run' button:

(code appears here)