<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># forLoops.py
"""Some examples used from lecture introducing for-loops
"""

print('Example: print every score in a list')
grades= [9,10,7,8]
for x in grades:
    print(x)


print('\nExample: sum elements of numeric list and print result')
my_list= [1,7,2]
s= 0
for x in my_list:
    s= s + x
print(s)


print('\nExample: average positive values in a list')
def ave_positives(my_list):
    """Returns: the average (float) of the positive values in a list.
    my_list: list of numbers with at least one positive value"""
    pass
    # Implement me
    # Or see lecture notes


print('\nExample: add 1 bonus point to every score in a list')
def add_bonus(grades):
    """Adds 1 to every element in a list of grades
    (either floats or ints)"""
    size = len(grades)
    for k in range(size):
        grades[k] = grades[k]+1

lab_scores = [8,5,10,9]
print("Initial grades are: "+str(lab_scores))
add_bonus(lab_scores)
print("With bonus, grades are: "+str(lab_scores))
</pre></body></html>