Code 1 Exercises

< CS101

These exercises will be part of the full homework-1 due Mon Apr 8th (logistics details to follow). The code here is stored in the browser, so you can't switch or share browsers. Just leave the tab with the exercises open (there's also a "retrieve" button at the bottom of the page) if you lose or close your tab.

Disclaimer: these early print exercises are a little dry, but we'll build this up to something more fun soon.

1.

The following code contains a syntax error, so it does not work. Fix the code so it produces the following output.

1 2 shoe


code-1-ex1

2.

The following code contains a syntax error, so it does not work. Fix the code so it produces the following output.

3 4 door


code-1-ex2

3.

The code below prints something when run. Change the code so it produces the following output when run:

1 2 3 hello


code-1-ex3

4.

The code below prints a single line when run. Change the code so it produces the following 3-line output when run

1
1 2
1 2 3


code-1-ex4


Each click of a Run button saves that code to disk on the computer running the browser. The button below retrieves all of the code exercises listed after the button.

count 4 : code-1-ex1 code-1-ex2 code-1-ex3 code-1-ex4

(code appears here)