Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, November 28, 2012

Codecademy: It's Okay to be Average


#sample solution



Lloyd = {
    "name":"Lloyd",
    "homework": [90,97,75,92],
    "quizzes": [ 88,40,94],
    "tests": [ 75,90]
    }
Alice = {
    "name":"Alice",
    "homework": [100,92,98,100],
    "quizzes": [82,83,91],
    "tests": [89,97]
    }
Tyler = {
    "name":"Tyler",
    "homework": [0,87,75,22],
    "quizzes": [0,75,78],
    "tests": [100,99.5,99.7]
    }

def average(numList):
sum = 0
for number in numList:
sum += number
return (float(sum)/len(numList))

print average(Tyler['tests'])

4 comments:

  1. Replies
    1. It looks like this:

      lloyd = {
      "name": "Lloyd",
      "homework": [90.0, 97.0, 75.0, 92.0],
      "quizzes": [88.0, 40.0, 94.0],
      "tests": [75.0, 90.0]
      }
      alice = {
      "name": "Alice",
      "homework": [100.0, 92.0, 98.0, 100.0],
      "quizzes": [82.0, 83.0, 91.0],
      "tests": [89.0, 97.0]
      }
      tyler = {
      "name": "Tyler",
      "homework": [0.0, 87.0, 75.0, 22.0],
      "quizzes": [0.0, 75.0, 78.0],
      "tests": [100.0, 100.0]
      }

      # Add your function below!
      def average(numbers):
      sum = 0
      for number in numbers:
      sum += number
      return (float(sum)/len(numbers))

      Delete
  2. The function looks like this

    def average(numbers):
    sum = 0
    for number in numbers:
    sum += number
    return (float(sum)/len(numbers))

    ReplyDelete


This is an example of scrolling text using Javascript.

Popular Posts