Modules 101
def modules():
import os #Built in
import random
import time
import math #Built in
#Find the .jpg files in a directory using os.listdir(directory)
fileList = os.listdir('I:\Documents and Settings\Cedric Stallworth\Desktop\Job CoC\Classes\Spring 2007\CS1315\Week 1')
print fileList
for file in fileList:
if file.endswith('.jpg'):
print file
#Show random.random() module at work
for i in range(1,10+1):
print random.random()
#Show random.shuffle(range) module at work
for i in range(1,10+1):
rng = range(1,10+1)
random.shuffle(rng)
print rng
#Show time
print time.time()
print time.ctime()
#A little Math
print math.pi
print math.cos(0)
print math.sin(0)
Link to this Page