Difference between revisions of "CSC111 Programs for Week 11 2015"
(Created page with "--~~~~ ---- =Aqarium.py (with bubbles)= <br /> <source lang="python"> # aquarium.gif # D. Thiebaut from graphics import * import random WIDTH = 700 # geometry of tank2.gif ...") |
|||
Line 7: | Line 7: | ||
# aquarium.gif | # aquarium.gif | ||
# D. Thiebaut | # D. Thiebaut | ||
+ | # This is a variation on the program seen during Week 10. This time we have a collection of | ||
+ | # bubbles that appear wherever the user clicks the mouse. | ||
+ | # | ||
from graphics import * | from graphics import * | ||
import random | import random | ||
Line 89: | Line 92: | ||
</source> | </source> | ||
<br /> | <br /> | ||
+ | =Emails.txt= | ||
<br /> | <br /> | ||
+ | <source lang="text"> | ||
+ | Ammie@hampshire.edu | ||
+ | Bessie@smith.edu | ||
+ | Carylon@smith.edu | ||
+ | Cheryll@smith.edu | ||
+ | Cordelia@smith.edu | ||
+ | Illa@smith.edu | ||
+ | Lisbeth@smith.edu | ||
+ | Mackenzie@smith.edu | ||
+ | Maryellen@smith.edu | ||
+ | Matha@smith.edu | ||
+ | Patrica@hampshire.edu | ||
+ | Sanjuana@smith.edu | ||
+ | Sharie@smith.edu | ||
+ | Sonya@smith.edu | ||
+ | Yuko@smith.edu | ||
+ | |||
+ | Cheryll@smith.edu | ||
+ | Codi@smith.edu | ||
+ | Cordelia@smith.edu | ||
+ | Elenore@smith.edu | ||
+ | Emelia@smith.edu | ||
+ | Josie@smith.edu | ||
+ | Lina@smith.edu | ||
+ | Lisbeth@smith.edu | ||
+ | Mackenzie@smith.edu | ||
+ | Margaretta@smith.edu | ||
+ | Rosalina@smith.edu | ||
+ | Sade@smith.edu | ||
+ | Sanjuana@smith.edu | ||
+ | Shelli@smith.edu | ||
+ | Sonya@smith.edu | ||
+ | |||
+ | Aja@hampshire.edu | ||
+ | Alesia@hampshire.edu | ||
+ | Bessie@smith.edu | ||
+ | Carylon@smith.edu | ||
+ | Chun@smith.edu | ||
+ | Codi@smith.edu | ||
+ | Constance@smith.edu | ||
+ | Felisa@smith.edu | ||
+ | Illa@smith.edu | ||
+ | Karena@hampshire.edu | ||
+ | Kortney@hampshire.edu | ||
+ | Lina@smith.edu | ||
+ | Mallie@smith.edu | ||
+ | Patrica@hampshire.edu | ||
+ | Zofia@smith.edu | ||
+ | |||
+ | Anna@hampshire.edu | ||
+ | Bessie@smith.edu | ||
+ | Candyce@smith.edu | ||
+ | Clorinda@smith.edu | ||
+ | Elenore@smith.edu | ||
+ | Karine@hampshire.edu | ||
+ | Kaylee@hampshire.edu | ||
+ | Kortney@hampshire.edu | ||
+ | Lisbeth@smith.edu | ||
+ | Marline@smith.edu | ||
+ | Matha@smith.edu | ||
+ | Porsha@hampshire.edu | ||
+ | Renata@smith.edu | ||
+ | Sanjuana@smith.edu | ||
+ | Sonya@smith.edu | ||
+ | |||
+ | Ammie@hampshire.edu | ||
+ | Anna@hampshire.edu | ||
+ | Birdie@smith.edu | ||
+ | Codi@smith.edu | ||
+ | Constance@smith.edu | ||
+ | Edelmira@smith.edu | ||
+ | Kaylee@hampshire.edu | ||
+ | Kristel@hampshire.edu | ||
+ | Margaretta@smith.edu | ||
+ | Moira@smith.edu | ||
+ | Patrica@hampshire.edu | ||
+ | Phuong@hampshire.edu | ||
+ | Sade@smith.edu | ||
+ | Tamela@smith.edu | ||
+ | Yuko@smith.edu | ||
+ | </source> | ||
+ | |||
<br /> | <br /> | ||
+ | =processEmails.py= | ||
+ | <br /> | ||
+ | <source lang="python"> | ||
+ | file =open( "emailAddresses.txt", "r" ) | ||
+ | emails = file.read() | ||
+ | file.close() | ||
+ | |||
+ | L = [] | ||
+ | for email in emails.split( "\n" ): | ||
+ | email = email.strip().lower() | ||
+ | if len( email ) == 0: | ||
+ | continue | ||
+ | L.append( email ) | ||
+ | |||
+ | #L.sort() | ||
+ | #print( L ) | ||
+ | #print() | ||
+ | L = list( set( L ) ) | ||
+ | print() | ||
+ | print( L ) | ||
+ | |||
+ | print( "\nSMITH EMAILS" ) | ||
+ | for email in L: | ||
+ | if email.find( "@smith" ) != -1: | ||
+ | print( email ) | ||
+ | print( "\n5-COLLEGE EMAILS" ) | ||
+ | for email in L: | ||
+ | if email.find( "@smith" ) == -1: | ||
+ | print( email ) | ||
+ | |||
+ | |||
+ | </source> | ||
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 12:03, 13 April 2015
--D. Thiebaut (talk) 12:50, 13 April 2015 (EDT)
Aqarium.py (with bubbles)
# aquarium.gif
# D. Thiebaut
# This is a variation on the program seen during Week 10. This time we have a collection of
# bubbles that appear wherever the user clicks the mouse.
#
from graphics import *
import random
WIDTH = 700 # geometry of tank2.gif
HEIGHT = 517
class Fish:
def __init__( self, fileNm, xx, yy ):
self.fileName = fileNm
self.x = xx
self.y = yy
self.image = Image( Point( xx, yy ), fileNm )
def draw( self, win ):
self.image.draw( win )
def moveRandom( self ):
deltax = - random.randrange( 10 )
deltay = random.randrange( -3, 3 )
self.image.move( deltax, deltay )
x = self.image.getAnchor().getX()
if x < -50:
self.image.move( WIDTH+100, 0 )
class Bubble:
def __init__( self, center ):
self.circ = Circle( center, random.randrange(5, 15) )
self.circ.setOutline( "white" )
def draw( self, win ):
self.circ.draw( win )
def moveRandom( self ):
deltaX = random.randrange( -3, 3 )
deltaY = random.randrange( -5, 0 )
self.circ.move( deltaX, deltaY )
# make bubbles wrap around...
if self.circ.getCenter().getY() < 0:
self.circ.move( 0, HEIGHT+50 )
def main():
# open the window
win = GraphWin( "CSC Aquarium", WIDTH, HEIGHT )
# display background
background = Image( Point( WIDTH//2, HEIGHT//2 ), "tank2.gif" )
background.draw( win )
fishList = []
for i in range( 4 ):
fish = Fish( "fish0.gif", i*100, 350 )
fish.draw( win )
fishList.append( fish )
# animation loop
bubbles = []
while True:
# move all fish
for fish in fishList:
fish.moveRandom()
# new bubble?
p = win.checkMouse() # did the user click the mouse?
if p != None: # None means no, a real Point means yes
b = Bubble( p ) # create a new bubble
b.draw( win ) # draw it
bubbles.append( b ) # add it to the list of bubbles
# move bubbles
for b in bubbles:
b.moveRandom()
win.close()
main()
Emails.txt
Ammie@hampshire.edu
Bessie@smith.edu
Carylon@smith.edu
Cheryll@smith.edu
Cordelia@smith.edu
Illa@smith.edu
Lisbeth@smith.edu
Mackenzie@smith.edu
Maryellen@smith.edu
Matha@smith.edu
Patrica@hampshire.edu
Sanjuana@smith.edu
Sharie@smith.edu
Sonya@smith.edu
Yuko@smith.edu
Cheryll@smith.edu
Codi@smith.edu
Cordelia@smith.edu
Elenore@smith.edu
Emelia@smith.edu
Josie@smith.edu
Lina@smith.edu
Lisbeth@smith.edu
Mackenzie@smith.edu
Margaretta@smith.edu
Rosalina@smith.edu
Sade@smith.edu
Sanjuana@smith.edu
Shelli@smith.edu
Sonya@smith.edu
Aja@hampshire.edu
Alesia@hampshire.edu
Bessie@smith.edu
Carylon@smith.edu
Chun@smith.edu
Codi@smith.edu
Constance@smith.edu
Felisa@smith.edu
Illa@smith.edu
Karena@hampshire.edu
Kortney@hampshire.edu
Lina@smith.edu
Mallie@smith.edu
Patrica@hampshire.edu
Zofia@smith.edu
Anna@hampshire.edu
Bessie@smith.edu
Candyce@smith.edu
Clorinda@smith.edu
Elenore@smith.edu
Karine@hampshire.edu
Kaylee@hampshire.edu
Kortney@hampshire.edu
Lisbeth@smith.edu
Marline@smith.edu
Matha@smith.edu
Porsha@hampshire.edu
Renata@smith.edu
Sanjuana@smith.edu
Sonya@smith.edu
Ammie@hampshire.edu
Anna@hampshire.edu
Birdie@smith.edu
Codi@smith.edu
Constance@smith.edu
Edelmira@smith.edu
Kaylee@hampshire.edu
Kristel@hampshire.edu
Margaretta@smith.edu
Moira@smith.edu
Patrica@hampshire.edu
Phuong@hampshire.edu
Sade@smith.edu
Tamela@smith.edu
Yuko@smith.edu
processEmails.py
file =open( "emailAddresses.txt", "r" )
emails = file.read()
file.close()
L = []
for email in emails.split( "\n" ):
email = email.strip().lower()
if len( email ) == 0:
continue
L.append( email )
#L.sort()
#print( L )
#print()
L = list( set( L ) )
print()
print( L )
print( "\nSMITH EMAILS" )
for email in L:
if email.find( "@smith" ) != -1:
print( email )
print( "\n5-COLLEGE EMAILS" )
for email in L:
if email.find( "@smith" ) == -1:
print( email )