Contents
- ./average2.py
- ./graphics_test.py
./average2.py 1/2
[top][prev][next]
# This program calculates and displays the average of two numbers
# by CS111 class
print("This program will average two numbers!")
print()
# get user input
# can use float or eval for these inputs. Probably should be consistent
# and just pick one or the other because it seems odd that they are
# different, but this just demonstrates that we can use either.
num1 = float(input("Give me a number: "))
num2 = eval(input("Give me another number: "))
# calculate the average
average = (num1 + num2)/2
# display the average
print("The average of", num1, "and", num2, "is", average)
./graphics_test.py 2/2
[top][prev][next]
# Graphics Test Script
# by Sara Sprenkle
from graphics import *
win = GraphWin("My Circle", 200, 200)
point = Point(100,100)
c = Circle(point, 10)
c.draw(win)
#c.setFill("yellow") # make it a yellow circle
#c.setOutline(color_rgb(200, 0, 200)) #give the circle a pretty fucshia outline
#c.setWidth(3) # make its outline wider
# demonstrate what happens, outside of IDLE, if the line below is commented out.
win.getMouse()
win.close()
Generated by GNU Enscript 1.6.5.90.