Competency Practice

READ CODE:

 

a=9

b=5

c=a-b

if a>c:

    print "first"

    while b<a:

        print"start",b

        b=b+2

b=5

while a>c:

    if c==6:

        print"do it",c

        a=a+1

    while b>0:

        print a+b-c

        b=b-2

    print"more",c

    b=a-c

    c=c+2

if a>1: print "last"

print "another",b

  

WRITE CODE:

 

Write a program to integer scores from the user until the user enters a number less than 0.

For each number entered, tell if it is an odd number over 50.  Once the loop is exited, print the average of all scores above 50, and the highest even score less than 50.

  

READ CODE:   Functions:

 

def first(a,b,c):

    print "in first",a,b

    return a+b

 

def second(b):

    a=2

    c=1

    print "before first",a,b,c

    a=first(c,a,b)

    print "in sec",a,b,c

    return a

 

a=3

b=4

print"begin"

c=second(a)

print "between calls"

b=first(b,c,a)

print "done",a,b,c

  

WRITE CODE:  =  Arrays:

 You have a filled list of scores called scores.  Write a Python function that does the following:   The function passes in the list and an integer called val.  It will return the sum of all numbers more than the val less than the highest score.  It also prints the average of all the odd numbers less than the total average.  Finally, it prints the position in the list of the second highest number