Difference between revisions of "Computer Science"

From WLCS
Line 1: Line 1:
 +
== Friday (12/10/10) ==
 +
'''Warmup:'''
 +
* Copy and paste the following code
 +
 +
<syntaxhighlight lang="Python">
 +
from gasp import *          # import everything from the gasp library
 +
 +
begin_graphics()            # open the graphics canvas
 +
 +
Box((20, 20), 100, 100)    # the house
 +
Box((55, 20), 30, 50)      # the door
 +
Box((40, 80), 20, 20)      # the left window
 +
Box((80, 80), 20, 20)      # the right window
 +
Line((20, 120), (70, 160))  # the left roof
 +
Line((70, 160), (120, 120)) # the right roof
 +
 +
update_when('key_pressed')  # keep the canvas open until a key is pressed
 +
end_graphics()              # close the canvas (which would happen
 +
                            # anyway, since the script ends here, but it
 +
                            # is better to be explicit).
 +
</syntaxhighlight>
 +
 +
* Recomment each line of code with Box() and Line()...what are the arguments into those functions?
 +
 +
'''Agenda:'''
 +
* [[Looping with GASP Exercises]]
 +
 
== Thursday (12/9/10) ==
 
== Thursday (12/9/10) ==
 
'''Agenda:'''
 
'''Agenda:'''

Revision as of 09:15, 10 December 2010

Friday (12/10/10)

Warmup:

  • Copy and paste the following code
from gasp import *          # import everything from the gasp library

begin_graphics()            # open the graphics canvas

Box((20, 20), 100, 100)     # the house
Box((55, 20), 30, 50)       # the door
Box((40, 80), 20, 20)       # the left window
Box((80, 80), 20, 20)       # the right window
Line((20, 120), (70, 160))  # the left roof
Line((70, 160), (120, 120)) # the right roof

update_when('key_pressed')  # keep the canvas open until a key is pressed
end_graphics()              # close the canvas (which would happen
                            # anyway, since the script ends here, but it
                            # is better to be explicit).
  • Recomment each line of code with Box() and Line()...what are the arguments into those functions?

Agenda:

Thursday (12/9/10)

Agenda:

Wednesday (12/8/10/)

Warmup:

  • Prompt the user for a number N
  • Print out the first N terms of the following sequence:
    • 1, 4, 9, 16, 25, 36, ...

Agenda:

Tuesday (12/7/10)

Warmup:

  1. Write a loop that runs 30 times (using x as a counter variable)
    1. Inside the loop, print x*" ","*"
    2. Don't forget to increment your counter variable
  2. Write another loop that runs from 30 down to 0
    1. Inside the loop, print x*" ","*"
    2. Don't forget to decrement your counter variable

Agenda:

Monday (12/6/10)

Warmup:

  1. Initialize a counter variable i to 1
  2. Create another variable old_i that starts at 1 also
  3. Create a loop that runs up to 1000
    1. print out i and old_i on the same line (use a comma)
    2. save i into old_i
    3. increment i
  • What happens when you execute the above code?

Agenda:

Friday (12/3/10)

Warmup:

  1. Initialize a counter variable i to 1
  2. Create another variable old_i that starts at 1 also
  3. Create a loop that runs up to 1000
    1. print out i and old_i
    2. save i into old_i
    3. increment i
  • What happens when you execute the above code?

Agenda:

Thursday (12/2/10)

Warmup:

  1. Prompt the user for a number N
  2. Initialize a counter variable named i to 0
  3. Using a loop, print out all the numbers up to N

Agenda:

Wednesday (12/1/10)

Warmup:

  • Create a loop counter variable i that starts at 0
  • Write a loop that counts down from 0 through -10 (What would the condition be?)
    • Print i inside the loop
    • Don't forget to decrement i!

Agenda:

Archives