Thursday, October 2, 2008

Intro to Programming

Write you answer as a comment. You should paste the questions into the comment:

Introduction to programming. During the second block
some of us will focus on programming, so we are giving an introduction here.

The command Local x makes a variable named x that is
only recognized by the program. It is like a box inside
the computer that has the label x and number can be put into it.
WRNUN x writes the value of the box on the screen.
Declare x does the same thing as local x but the name is
recognized by all other programs (names).
LOOP is the same as REPEAT and is used for programming.

What do you think will happen on the screen and why? We will discuss in class on Thursday.
For every answer write also a clear explanation.


NEW A
local x
x=6 wrnum x

Answer________
Explanation


NEW B
Local t
t=4 wrnum t
Answer________
Explanation

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer________
Explanation

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer________
Explanation

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer________
Explanation

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer________
Explanation

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer________
Explanation

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer______
Explanation

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer______
Explanation

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer______
Explanation

9 comments:

Dani said...

Comment by Dani:

NEW A
local x
x=6 wrnum x

Answer 6
Explanation: We first define the variable x. Then we set x to 6 and
finally we write the answer on the screen. The order is important. If instead we type "wrnum x x=6", then the number 0 will be displayed.


NEW B
Local t
t=4 wrnum t
Answer________
Explanation

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer________
Explanation

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer________
Explanation

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer________
Explanation

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer________
Explanation

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer________
Explanation

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer______
Explanation

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer______
Explanation

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer______
Explanation

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer 6
Explanation: We define the variable x, then we set x to 6 and get the answer on screen.

NEW B
Local t
t=4 wrnum t
Answer 4
Explanation: The same concept as above, we defined the variable t as 4, thus the answer is 4.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer 0
Explanation: The answer is 0 since t is defined as t=0, and the order is important, so anything after "wrnum t" doesn't count.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer 0.1
Explanation: Since t is defined as 0 and then t+0.1, it would be 0+0.1, thus it will be 0.1

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer 0 and 0.2
Explanation: This is due to the fact that "t=0 wrnum t" would write a zero, then the "t=t+0.2 wrnum t."

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer 1
Explanation: This since the answer would be initially 0.01 and then the loop command would multiply that number by a hundred, thus equalling 1.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer 0; 0.01; 0.02; 0.03;...
Explanation: Since the wrnum command is being looped it's going to list the variable then the number added by 0.01 by a hundred times.

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer 1
Explanation: 0 would be initially added by 0.0001, then it would've been multiplied by the loop command by 10000, equalling 1.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer: A circle with diameter 300.
Explanation: The answer initially would 1, but then with the command "x=300*t" it would multiply that number by 300, then due to the command "circle x," it comes out as a circle with the diameter of 300, rather than a number since there is no "wrnum" command.

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer: A rainbow coloured circle with diameter 200.
Explanation: With the same concept as above, the "x=200*t" defines the diameter as 200, and then "h= 360*2*t" is what creatures the different coloured circles with each a radius of 2. And the "color hsb h 100 100" is what allows the "h-360*2*t" to work, since it colours and defines what hues to use.

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer 6
Explanation: We defined that there is a x variable, then we defined it as 6. The wrnum x command showed the defined x on the screen, which was 6.

NEW B
Local t
t=4 wrnum t
Answer 4
Explanation We defined that there is a x variable, then we defined it as 4. The wrnum x command showed the defined x on the screen, which was 4.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer 0
Explanation We defined that there was a variable t, then we defined t as 0. The wrnum command will show the 0 because at that point, t is still defined as 0. The t was then changed to t+.1, which will be .1, but it will not change the screen because we change it after the wrnum t command.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer 0.1
Explanation t has been declared as a variable for all of the screens. We will define t as 0, then define t again as t+0.1, using the original t=0 as the t in the equation. the wrnum t command makes the 0.1 show up, because that's what the new t is.

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer 0.2
Explanation t has been declared as a variable for all of the screens. We will define t as 0, then define t again as t+0.2, using the original t=0 as the t in the equation. the wrnum t command makes the 0.2 show up, because that's what the new t is.

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer 1
Explanation t has been declared as a variable for all the screens. we first define t as 0, then tell the computer to loop the command [t=t+0.01] 100 times. The first repetition shows that 0+0.01 is .01, then the t is .01. The second repetition would be .01+.01=.02, since the t is already .01. Now the t is .02, and it increases 100 times until it reaches 1. The wrnum command then shows the number 1.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer
0
0.01
0.02
...
0.99
1
Explanation t is declared as a variable already so we start off with t equal to 0. We then declare we are going to loop the command [wrnum t t=t+0.01 ] 100 times. This command will write the existing t, then increase it by .01. By repeating this 100 times, we have a list of 100 numbers increasing from 0 by .01 each time.

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer 1
Explanation t has been declared as a variable for all the screens. we first define t as 0, then tell the computer to loop the command [t=t+0.0001] 10000 times. The first repetition shows that 0+0.0001 is .0001, then the t is .00001. The second repetition would be .0001+.0001=.0002, since the t is already .0001. Now the t is .0002, and it increases 10000 times until it reaches 1. The wrnum command then shows the number 1.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer: A Circle increasing in size 10000
Explanation t is already declared as a variable for all screens. we define x as another variable just for this screen. we define t as 0 then we ask the computer to loop the command [t=t+0.0001 x=300*t circle x ] 10000 times. it starts off by adding .0001 to the t value of 0, then defines x as 300 times the t value. we then tell the computer to draw a circle with a radius of the x value, which is 300 times the resulting t value. we repeat this whole process 10000 times with the t value increasing .0001 each time, making the radius of the circle increase each time.

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer A circle expanding from the center going through all of the colors as it expands
Explanation t is declared as a variable for all screens. we then define that we have variables x and h, and then define t as 0. we ask the computer to repeat the command [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ] 10000 times. this command means that we are adding .0001 to the initial t value each time, then x is that new t value multiplied by 200. we say h is 360 multiplied by 2 multiplied by our new t value, and then the color changes by that h value each time, drawing a circle of increasing x value each time the command is repeated, which is 10000 times.

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer: 6
Explanation: First, the variable x is defined, then x is set to 6 and the answer appears on the screen.


NEW B
Local t
t=4 wrnum t
Answer: 4
Explanation: First, the variable x is defined, then x is set to 4 and the answer appears on the screen.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer: 0
Explanation: The first t is defined first as 0, and since the wrnum isn't repeated, the computer ignores it. So the x is defined and set to 0.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer 0.1
Explanation: Since the order is t+0.1 comes before wrnum t, the computer recognizes is and

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer: 0 and 0.2
Explanation: Since wrnum appears after both values of t, the computer will put both numbers on the screen.

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer: 1
Explanation: The computer only shows 1 because wrnum appears after the loop command. If it were to appear before, then all the numbers leading up to 1 would be shown, but the order dictates that only the final number should be shown.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer: Every number between 0 and 1 increasing by 0.01.
Explanation: Since the wrnum appears inside the brackets for the loop command, the computer knows to write every number that increases 0 by 0.1 for a hundred times.

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer: 1
Explanation: The computer is increasing 0 by 1000 by increments of 0.0001. The final answer is 1, but the computer only shows the final answer instead of all the increments because the wrnum t appears at the end of the command.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer An increasing circle
Explanation: T starts as being defined as 0. The loop command is told to repeat t by increments of 0.0001 and defines the variable x as 300 times the amount of t. The final portion of the command claims that there is also a circle that is to be repeated of diameter x. This means that the circle's diameter is going to be increased by 300 times t (0.0001). Therefore, the answer is a circle that increases by this 1000 times.

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer A repeating rainbow circle
Explanation: There are two variables in the beginning, x and h. T starts at 0, and the command to be repeated 10000 times is basically that t should increase by 0.0001 (10000 times), that x is the increasing t times 200, and h is 360 times 2 times the increasing t. Color is added with hue, saturation and brightness, which cues the rainbow, and the circle x (which means a circle increasing by 200*t) makes the rainbow in a circle formation.

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer____6____
Explanation It's like algebra. If you make x = 6, when you type wrnum, the computer searches a local variable, which is x, and since x =6, it writes 6 on the screen .

NEW B
Local t
t=4 wrnum t
Answer____4____
Explanation
You create the local variable, a box named 't'. Then you give 't' the identity of 4. So when you type wrnum, you are asking the computer to find the box named t and it shows it's identity of 4 on the screen.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer___0.1_____
Explanation
You create a box named t. You give the t the identity of 0. When you ask the computer tofind the identity of t, a 0 will appear. If you add to it, it will gain a new identity of 0.1 because it is adding the 0.1 to the original 0.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer____0.1____
Explanation
same as above, except it is recognized by the entire computer rather than the single program.

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer____0.2____
Explanation
same as above

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer_____1___
Explanation
by writing declare t, you create a global variable named t. By making t = 0, that is giving the

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer________
Explanation

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer______
Explanation

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer______
Explanation

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer______
Explanation

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer 6
Explanation: The x variable is set to six. Wrnum put the x value on the screen. The answer is six.

NEW B
Local t
t=4 wrnum t
Answer 4
Explanation: The x variable is set to four. Wrnum put the x value on the screen. The answer is four.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer 0
Explanation: The x variable is set to 0. Wrnum put the x value on the screen. Based on the equation, the content of the box increases by 0.1,but this value is not displayed.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer 0.1
Explanation: The variable t is set to zero. As t increases by 0.1, the value remains the same in comparison to wrnum which puts the value on the screen.

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer 0.2
Explanation: The variable t is set to zero. As t increases by 0.2, the value remains the same in comparison to wrnum which puts the value on the screen.

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer 1
Explanation: The variable t is set to zero. The loop function takes the equation in the brackets and defines a new answer. Wrnum t writes the value on the screen.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]
Answer 0.8
Explanation: The variable t is set to zero. The loop function repeats the equation. The values are repeated to match the equation.

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer 1
Explanation: The variable t is set to zero. The loop function takes the equation in the brackets and defines a new answer. Then, wrnum t writes the value on the screen.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer Big black circle
Explanation: Start with time=0 and add 0.0001. If you do this a thousand times, the answer will be one. If you multiply 300 by 1, a big black circle will appear.

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer Medium-sized colorful circle
Explanation: Start with t=0 and add 0.0001. If you do this a thousand times, the answer will be 1. If you multiply one by 200 and by hue 360 times 2 with hsb, a medium-sized colorful circle will appear.

Anonymous said...

NEW A
local x
x=6 wrnum x

Answer - 6
Explanation
when we enter NewA into SeeLogo it makes a box called x and writes 6 in the centre of the screen for us.


NEW B
Local t
t=4 wrnum t
Answer___4_____
Explanation
Same as NewA, it makes a 4.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer____0.1____
Explanation
the computer makes a box called t and does the math problem that we ask it to, if we put wrnum after the main lines it will give us the answer.

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t
Answer___0.1_____
Explanation
the computer made a box called t when we declared it, then it executed the problem we gave it and wrote the number.

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer___0.2_____
Explanation
The computer had the t box and the 0 then added o.2 to it, then wrote it in the screen.

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer___1_____
Explanation
the computer executed the problem we gave to it and wrote the number in the centre of the screen. With the loop and brakets it came out as 1.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer___0.01-0.1_____
Explanation
the computer makes a box and on the loop adds 0.01 to the number before it 100 times. Starting at 0 till we get to 1.
New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer___1___
Explanation
the computer started with t as 0 and added 0.0001 a 1000 times then wrote it on the screen.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer___black repeating circle___
Explanation
The computer made a box called x then set t as 0 then added 0.0001 a 1000 times making 1. The x becomes 300 and a circle with the diameter of x. T is our time and it starts with zero and makes the circle according to the time.
NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer___a rainbow circle___
Explanation
Again, t is our time and it goes from 0 to 1 but instead of just having a plain circle we have x as 200 and a hue of 360 that gets multiplied and we use hsb to make the different levels of colours.

Anonymous said...

THIS IS NOT FINISHED. SORRY!!!

NEW A
local x
x=6 wrnum x

Answer: 6
Explanation: First a box with label "x" is created (inside the computer) but nothing is printed yet. Next the number 6 is put inside the box (x=6 wrnum x).


NEW B
Local t
t=4 wrnum t

Answer: 4
Explanation: The number four appeared in the screen. This is because we named the box "t" and then the computer wrote (t=4 wrnum t) the number in the box.

NEW C
Local t
t=0 wrnum t t=t+0.1

Answer: 0
Explanation: First a box with label "t" is created (inside the computer)but nothing is printed. Next the number 0 is put in the box and the contents of the box is displayed on the screen. Finally, the contents of the box increases by 0.1 (but is not displayed).

Start a new seelogo

DECLARE t

NEW A
t=0 t=t+0.1 wrnum t

Answer: 0.1
Explanation: First when you declare "t" it creates a box (inside the computer) that will inform the rest of the equations. Next the number 0 is put inside the box, then the number of the box is increased by 0.1 and then the computer writes it (wrnum t) on the screen.

NEW B
t=0 wrnum t t=t+0.2 wrnum t

Answer: 0
0.2
Explanation: The box is made already from the declare "t" command. Then the number 0 appears in the box and the computer writes it (it appears on the screen). Then "t" is increased by 0.2 and the computer writes it again (it appears under the 0).


NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t

Answer: 1
Explanation: First, "t" is defined as 0 and then the loop command tells it to add 0.01 to "t" every time. Then the number 100 tells it to loop (add 0.01 to "t") "t" 100 times. Then it tells it to write it (wrnum t) and the number 1 is printed.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer: 0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08

Explanation: First the number 0 appears in the box then the loop tells the "t" to repeat itself, each time adding 0.01 to "t". And each time the answer is printed on the screen so that you can see the progression of the numbers that are added.


New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t

Answer: 1
Explanation: First, "t" is defined as 0 and then the loop command tells it to add 0.0001 to "t" every time. Then the number 10000 tells it to loop (add 0.0001 to "t") "t" 10000 times. Then it tells it to write "t" (wrnum t) and the number 1 is printed.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]

Answer: black repeating circle
Explanation:

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]

Answer:
Explanation:

Emily said...

NEW A
local x
x=6 wrnum x

Answer 6
Explanation: The variable x is given the value of 6, and "wrnum x" writes that value on the screen.


NEW B
Local t
t=4 wrnum t
Answer 4
Explanation: B is basically the same as A, only the variable is defined as "t" and the value it's given is 4.

NEW C
Local t
t=0 wrnum t t=t+0.1
Answer 0
Explanation: The command "wrnum t" writes the number to the screen. Without that command, "t=t+0.1" will not be written on the screen. So the only thing written on the screen is the answer to "t=0" (which is followed by "wrnum t").


NEW A
t=0 t=t+0.1 wrnum t
Answer 0.1
Explanation: First, the variable t was given the value of 0. Instead of being followed by "wrnum t" (which would write a 0 on the screen), it was followed by a second equation, "t=t+0.1," which the computer understands as "t=0+0.1" (due to the previous equation). Because the two equations together were followed by "wrnum t," only the second equation was written on the screen.

NEW B
t=0 wrnum t t=t+0.2 wrnum t
Answer 0, 0.2
Explanation: Both equations were each followed by the command "wrnum t," so both were written on the screen. Due to the first equation of t, the computer reads the second equation as "t=0+0.2".

NEW C
t=0 loop 100 [t=t+0.01 ] wrnum t
Answer 1
Explanation: T is initially given the value of zero. The command “loop 100 [t=t+0.01]” takes the equation “t=t+0.01” (or “t=0+0.01”) and repeats it 100 times. Because 0+0.01 equals 0.01, and 0.01 multiplied by 100 equals one, the answer for the entire command is simply 1.

NEW D
t=0 loop 100 [wrnum t t=t+0.01 ]

Answer 0, 0.01, 0.02…0.98, 0.99, 1
Explanation: In the previous problem, the only number written on the screen was the end result of the loop of “t=t+0.01” one hundred times. In this problem, “wrnum t” was looped as well, so all of the numbers were written on the screen.

New E
t=0 loop 10000 [t=t+0.0001 ] wrnum t
Answer 1
Explanation: The explanation is basically the same as for C (t=0 loop 100 [t=t+0.01 ] wrnum t), except the numbers deal with thousands and thousandths instead of hundreds and hundredths. The answer is one, because one thousand times one thousandth equals one.

New F
LOCAL x
t=0 loop 10000 [t=t+0.0001 x=300*t circle x ]
Answer A repeating black circle with end diameter of 300
Explanation: This problem follows the same rules as those preceding it. T is initially set as zero, then the computer is told to loop the equation “t=t+0.0001” ten thousand times. The catch, however, is that there is a second variable, x, which is given the value of 300 times t (within the loop). Then, instead of being followed by the command “wrnum x,” it’s follwed by “circle x,” which makes the answer a circle instead of a number. The final circle has a diameter of 300 because 10000 times 0+0.0001 equals one, times three hundred is three hundred. Had the final command been “wrnum x,” the answer on the screen would have been the numbers 0.03, 0.06, 0.09...299.97, 300.

NEW G
LOCAL x h
t=0 loop 10000 [t=t+0.0001 x=200*t h=360*2*t color hsb h 100 100 [circle x] ]
Answer A repeating rainbow colored circle with a final diameter of 200
Explanation: This problem works much the same as the one previous to it, but it adds hsb into the mix with the new variable “h.” The circle goes through the rainbow of colors twice due to the two in “h=360*2*t.” The t in that equation is what makes the color vary. Without the t, the circle would just appear red (because the multiplication of t includes the hue in the increasing loop). Remarkably, should the “[circle x]” be changed to “[wrnum x],” the numbers only appear in red, without a vary in color.