Contents

  1. sum5.py
  2. tictactoe_clone.py
  3. tictactoe.py

sum5.py 1/3

[
top][prev][next]
# This program adds up 5 numbers from the user.
# By CS111, 09.25.2012

# A constant - makes program easier to change
# Convention: All capital letters
NUM_INPUTS = 9

print("This program will add up", NUM_INPUTS, "numbers given by the user.")

total = 0

for i in range(1, NUM_INPUTS + 1):  # alternatively, for i in range(5)
    num = eval( input("Enter a number: ") )
    total += num
    
print("The total is", total)


tictactoe_clone.py 2/3

[
top][prev][next]
# Create full-size tic-tac-toe board
# By CSCI111

#
# NOT COMPLETE YET
#

from graphics import *

WINDOW_DIM=200

tictactoeBoard = GraphWin("Tic Tac Toe Board", WINDOW_DIM, WINDOW_DIM)

width = tictactoeBoard.getWidth()
height = tictactoeBoard.getHeight()

# first vertical line
point = Point(WINDOW_DIM/3, 0)
point2 = Point( WINDOW_DIM/3, WINDOW_DIM )
vline = Line(point, point2)
vline.setOutline("purple")
vline.setWidth(3)
vline.draw(tictactoeBoard)

# second vertical line
vline2 = vline.clone()
vline2.move(WINDOW_DIM/3, 0)
vline2.draw(tictactoeBoard)

# create and draw first horizontal line

# create and draw second horizontal line

tictactoeBoard.getMouse()

tictactoe.py 3/3

[
top][prev][next]
# Create full-size tic-tac-toe board
# By CSCI111

#
# NOT COMPLETE YET
# 

from graphics import *

WINDOW_DIM=200

tictactoeBoard = GraphWin("Tic Tac Toe Board", WINDOW_DIM, WINDOW_DIM)

width = tictactoeBoard.getWidth()
height = tictactoeBoard.getHeight()

# first vertical line
point = Point(WINDOW_DIM/3, 0)
point2 = Point( WINDOW_DIM/3, WINDOW_DIM )
vline = Line(point, point2)
vline.setOutline("purple")
vline.setWidth(3)
vline.draw(tictactoeBoard)

# second vertical line
point3 = Point(WINDOW_DIM*2/3, 0)
point4 = Point( WINDOW_DIM*2/3, WINDOW_DIM )
vline2 = Line(point3, point4)
vline2.setOutline("purple")
vline2.setWidth(3)
vline2.draw(tictactoeBoard)

# create and draw first horizontal line

# create and draw second horizontal line

tictactoeBoard.getMouse()

Generated by GNU enscript 1.6.4.