CS Lab Week 5

1.  Function Review,  parameters,  main()

def first(a):
    print "in first",a,b
    c=second(a,b)
    print "end first",a,b,c
    return a+b

def second(b,c):
    a=1
    print "in sec",a,b,c
    return a+c

a=7
b=5
print"begin"
c=first(b)
print "between calls"
b=second(c,a)
print "done",a,b,c

2.  Fill Arrays and Lists from Files

def fillArray():
    fileName = raw_input("What file are the numbers in? ")
    infile = open(fileName,'r')
    scores = []

    for line in infile.readlines():
        scores.append(line)

    for s in scores:
        print s

    print scores[0]
    print scores[1]
    print scores[len(scores)-1]

fillArray()

3.  Make a new batch of test scores

        *** use print and comment to debug code:  Check vars

4.  Find all scores in the 80s

5.  Find all test scores within 10 of the highest score

6.  Put the highest 2 scores at the front of the list

7.  Bubble,Insertion sort,  Quick Sort,  Binary Search

8.  Homework:

          -Menu:
          -Print all scores between the average score and the high score
          -Print the average of all scores more than 5 below the total average
          -print the highest score that falls after the highest score in the list
          -Do a sort (Quick,Bubble,Insertion) on the list
          -Do a Binary Search on the list

VISUAL Python

1.  Target questions

2.  Collision Problem

      -http://en.wikipedia.org/wiki/Elastic_collision

3.  Homework:  Collision

4.  Project


 

AttachmentSize
2dcollisions.pdf84.01 KB