Skip to content

Instantly share code, notes, and snippets.

@bmontana
bmontana / button.py
Created February 28, 2018 13:38
A button class
# button.py
from graphics import *
class Button:
"""A button is a labeled rectangle in a window.
It is activated or deactivated with the activate()
and deactivate() methods. The clicked(p) method
returns true if the button is active and p is inside it."""
@bmontana
bmontana / dieview.py
Created February 28, 2018 13:29
DieView is a widget that displays a graphical representation of a standard six-sided die.
# dieview.py
from graphics import *
class DieView:
""" DieView is a widget that displays a graphical representation
of a standard six-sided die."""
def __init__(self, win, center, size):
"""Create a view of a die, e.g.:
d1 = GDie(myWin, Point(40,50), 20)
creates a die centered at (40,50) having sides
@bmontana
bmontana / U10_Ex02_Babysitter.py
Created February 23, 2018 23:19
GUI version of babysitting program from Unit 7
# U10_Ex02_Babysitter.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 24 Oct 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 2
@bmontana
bmontana / Card.py
Created February 16, 2018 19:52
Implementation of a class for a playing card
# Card.py
"""Class for playing cards"""
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 12 Feb 2018
# IDE: PyCharm Community Edition
#
# Assignment Info
@bmontana
bmontana / U09_S00_Racquetball.py
Created January 29, 2018 16:57
Simulate N games of racquetball for two players
# U09_S00_Racquetball.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 23 Jan 2018
# IDE: PyCharm Community Edition
#
# Assignment Info
# Sample problem 0
@bmontana
bmontana / U08_Ex10_FuelEconomy2.py
Created December 5, 2017 19:27
Computes the fuel efficiency of a multi-leg journey | Data comes from a file. | Format: first line is starting odometer reading subsequent lines contain next odometer reading, space, fuel consumption for this leg
# U08_Ex10_FuelEconomy2.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 23 Nov 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 10
@bmontana
bmontana / U08_Ex09_FuelEconomy1.py
Created December 5, 2017 19:25
Computes the fuel efficiency of a multi-leg journey
# U08_Ex09_FuelEconomy1.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 23 Nov 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 9
@bmontana
bmontana / U08_Ex08_GCDEuclid.py
Created December 5, 2017 19:25
Finds the greatest common divisor using Euclid's algorithm | n, m = m, n%m repeatedly until m is 0
# U08_Ex08_GCDEuclid.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 22 Nov 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 8
@bmontana
bmontana / U08_Ex07_Goldbach.py
Created December 5, 2017 19:24
Checks the Goldbach conjecture for numbers input by user. The Goldbach conjecture asserts that every even number is the sum of two prime numbers.
# U08_Ex07_Goldbach.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 22 Nov 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 7
@bmontana
bmontana / U08_Ex06_Primes.py
Created December 1, 2017 18:57
Finds every prime number less than or equal to a given number. Uses is_prime() from U08_Ex05_isPrime.py
# U08_Ex06_Primes.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 22 Nov 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 6