IB Computer Science 1

From WLCS
Revision as of 11:20, 8 March 2011 by Admin (talk | contribs)

Tuesday (3/8/11)

Warmup:

  1. Create a list with the following numbers: 6, 3, 8, 4, 3, 5, 4, 3, 2, 1, 6, 8, 9, 6, 7, 3, 7, 2, 5
  2. Create a variable named total and initialize it to 0 (zero)
  3. Use a loop to traverse the list
    • Add each list element to the total
  4. Print out your total after the loop is done

Agenda:

Friday (3/4/11)

Warmup:

  • Write the loop that finds the index of the first vowel
  • Print out the index

Agenda:

Wednesday (3/2/11)

Warmup:

Agenda:

Monday (2/28/11)

Warmup:

  • Variable scope
  • Without using a computer write down answers to the following questions about the following code:
  1. Where is 'myVar' defined (created)?
  2. In what order will the print statements be run?
  3. What value will 'myVar' have each time?
    Now copy the program into Python and test it.
  4. What values were actually printed?
  5. Was this the same or different from what you expected? Why so? Discuss with your partner.
  6. Inserted the following line at line 5 (just after the 'def test' line)
    print "In test, at start, myVar=", myVar
    Why does this create an error?
myVar=0
print "At start, myVar=",myVar

def test(input_var):
    myVar=input_var+1
    print "In test, at end, myVar=",myVar
    
myVar=1
print "Before test, myVar=:",myVar

test(myVar)
print "At end, myVar=:",myVar

Agenda:

  1. Brief lesson on scope
  2. Scope exercises (please wait until after lesson before commencing)
    Submit to weblockers when you're done - don't forget your name.
  3. Return strings tests
  4. (Basic) Python List Exercises
  5. Advanced Python List Exercises
  6. Convert your Dodge and Robot games to list format.
    For multiple items (e.g. falling objects in Dodge or coins in Robot) - create three lists: one for the object's graphics, and one each for its x and y coordinates. Replace your old, repetitive code with a loop that creates the objects and inserts their data into these lists.
  7. Mr. Fowler logs off

Thursday (2/24/11)

Warm Up:

Agenda:

  • Strings quiz : closed book.

Then

Tuesday (2/22/11)

To start

  • Work on your list exercises (see previous class's agenda).

Agenda:

  • Review Strings - quiz this Thursday. 15 mins
  • NOVA placement testing

Thursday (2/17/11)

Warmup:

  1. Create an empty list
  2. Append three numbers to the list
  3. Iterate through the list, printing each element's index next to its value
    • e.g. "1: 101"

Agenda:

Tuesday (2/15/11)

Warmup:

  1. Create a string named "String Review" and store it in a variable s
  2. print out a message that says, "s is # characters long" where ## should be a call to the len() function
  3. print out the first character in s by using the [] operator
  4. print out the last character in s by using the [] operator and len(s)-1
  5. Write a while loop that prints out every single character in s

Agenda:

Friday (2/11/11)

Warmup:

  • Jot notes on the following questions:
  1. In Robot or Dodge, which objects were similar (e.g. part of a set)? Look back at your code if need be.
  2. When working with those objects (e.g. checking for a collision), what did you have to do?
  3. How would you pass the whole set of objects to a function?
  4. Can you think of any problems with these approaches?

Agenda

  • Submit Dodge, whether or not it works.
  • String exercises HTTLACS: Ch7 #5,6,7
  • Demo string exercises
  • Optional extension exercises from Ch 7: #1,2, 8-10

Wednesday (2/9/10)

Warmup:

  • Create strings for the following: "Animation", "Collision", "Keyboard", "Bouncing"
  • Write a program that prints the word that starts earliest in the alphabet
  • Test it works
  • Fix it so it works regardless of upper/lower case.
    Hint: to convert a string to lower case, call 'stringVar.lower()'
  • Test it works by changing the case of some of the words

Agenda

  • Submit Email Harvester to weblockers, if you haven't already - name it 'LAST-NAME_FIRST-NAME_HARVESTER.py'
  • If you haven't already: Demo and submit Dodge. Today is the last class period to work on that (submit that too)
  • Complete HTTLACS: Ch7 exercises #5,6,7
    • Optional extension exercises from Ch 7: #1,2, 8-10
  • If you've done everything, study lists HTTLACS Ch 9. Do exercises 1-5.

Monday (2/7/10)

Warmup: Let's practice writing GASP code from scratch (15 minutes)

  1. Create a new program named gaspReview.py
  2. Open a graphics window
  3. Display a circle on the screen and save it as a variable named c
    • Be sure to create x and y variable coordinates for it
  4. Create a while loop that moves the circle across the screen to the right
    • If the circle's x-coordinate moves beyond the right side, change it's x-coordinate to 0
    • Randomize the y-coordinate between 0 and 600
  5. Test out the program
  6. Optional: if it runs, then try adding 2 more circles that have different speeds

Agenda

  • Demo/submit Email Harvester, if you haven't already
  • Demo Dodge (submit that too)
  • Complete HTTLACS: Ch7 #7,8,9. Optional extensions: 1,2,5-10

Wednesday (2/3/11)

Warmup:

  • Build up a string
s = ""
x = 0
while x < 5:
  s = s + "a"
  x = x + 1
  print s
  • What is printed out after the code executes? (DO NOT USE A COMPUTER)

Agenda:

Tuesday (2/1/11)

Warmup:

  • Create a small program that counts the number of vowels in a string.
    • Example: "IceBerg" returns 3, and "IBM invented the mainframe!" returns 8.
  • If you're done, extend the program to count consonants too.
    • "IceBerg" has 4 and "IBM invented the mainframe!" has 14.

Agenda:

Friday (1/28/11)

Snow day

Wednesday (1/26/11)

Warmup:

  • Put the following sentence in a string:
Maybe there are greater aggravations in your life, but the symmetrical-on-the-outside, asymmetrical-on-the-inside USB connector has been a source of frustration since its introduction.
  • Write a small program that iterates through the string from the end and prints out every word in reverse order.
    • Hint: keep track of the index of the current word's last letter.
  • For bonus points, detect when words are separated by any punctuation mark, not just a space. Don't print the punctuation itself.

Agenda:

Monday (1/24/11)

Warmup:

  • Using python, create a string "Weʼre Building a Better Internet", and save it in variable sample.
  • Write expressions that:
    • Print the first character
    • Print the third character (the apostrophe)
    • Print the second from last character
    • Print the word 'Building'

Agenda:

Thursday (1/20/11)

Agenda:

Friday (1/14/11)

Agenda:

Wednesday (1/12/11)

Warmup:

  • Without using the computer, what does the following code display?
from gasp import *
begin_graphics(width=800, height=600, title="Question 23")

x = 0
while x < 100:
  Circle( (400 + x, 300), x )
  x = x + 10

update_when('key_pressed')
end_graphics()

Agenda:

Monday (1/10/11)

Agenda:

Thursday (1/6/11)

Agenda:

  • 2nd Quarter Exam will be on Monday (1/10/11)
  • 2nd Quarter Exam Review
  • input, output, variables, and math expressions
  • functions
    • function definitions
    • function header
    • function body
    • return keyword
  • if statements
    • comparison operators
      • ==
      •  !=
      • <
      • >
      • <=
      • >=
    • Boolean operators
      • and
      • or
      • combining Boolean operators
  • while loops
    • sequences
    • break keyword
  • GASP
  • Catch/Follow game
  • Exam Format:
    • Open and closed-book sections
    • Multiple-choice
    • Short-answer code
    • Identify syntax errors
    • Identify the purpose of code sections

Tuesday (1/4/11)

Warmup:

  • Write the while loop that generates the first N terms of the following sequence (prompt for N):
    • 1, 2, 4, 7, 11, 16, 22, ...

Agenda:

Thursday - Friday (12/23/10 - 12/31/10)

  • Non-denominational winter break

Wednesday (12/22/10)

Tuesday - Monday (12/14/10 - 12/20/10)

Agenda:

Wednesday - Friday (12/8/10 - 12/10/10)

Warmup:

  • Listed below are the major components of pretty much every type of game
    1. game loop
    2. game information and objects
    3. game rules/behavior
    4. refresh screen
  • What is the programming construct/concept that we use for each of the above?

Agenda:

Monday (12/6/10)

Warmup:

  1. Copy, paste, and execute the code from Section 8.8 in Case Study: Catch
  2. Make sure you understand how the code works
  3. Comment sections of the code to explain what those lines do

Agenda:

Thursday (12/2/10)

Agenda:

Archives