Skip to content

Instantly share code, notes, and snippets.

@jonatasnona
Last active August 9, 2016 03:32
Show Gist options
  • Save jonatasnona/f093c734eda1c960cc6993afe48bbe09 to your computer and use it in GitHub Desktop.
Save jonatasnona/f093c734eda1c960cc6993afe48bbe09 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
# generating the list of integers
numbers = [random.randint(0,10) for num in range(1, 8)]
print "array:", numbers
# calculate average
average = reduce(lambda x, y: x + y, numbers) / float(len(numbers))
print "average: %.2f" % average
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment