Skip to content

Instantly share code, notes, and snippets.

@IanMcT
IanMcT / grade12oop_.idea_grade12oop.iml
Created October 11, 2016 21:17
Grade 12 War Card Game
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
@IanMcT
IanMcT / animation_if.py
Created October 11, 2016 02:10
Animates two balls that bounce on the screen.
#import libraries
#Uses http://stackoverflow.com/questions/13215215/python-tkinter-animation
import tkinter
#Set width, height, frames per second and how long to cross
CANVAS_WIDTH = 800
CANVAS_HEIGHT = 600
FPS = 120
SECONDS_TO_CROSS = 1.5
@IanMcT
IanMcT / oopics4uunit2_.idea_.name
Created October 3, 2016 10:08
starting code for card game to model OOP.
oopics4uunit2
@IanMcT
IanMcT / binaryReadWrite.py
Created September 29, 2016 09:38
Example program that uses a dictionary object and reads and writes to a binary file.
import pickle #used to serialize the data
import os.path
#Comment this code
#global variables
songs_and_bands = {"Drive": "Judge Jackson"}
def open_file():
global songs_and_bands #get global variable
if os.path.isfile('songs_and_bands.dat'):
binary_file=open('songs_and_bands.dat','rb')
@IanMcT
IanMcT / 4uconversions.py
Created September 26, 2016 18:46
Demonstrates conversions
def output_variables():
print("w:", w, "Type:", type(w))
print("x:", x, "Type:", type(x))
print("y:", y, "Type:", type(y))
print("z:", z, "Type:", type(z))
w = 3.2
x = 3.8
y = -3.2
z = -3.8
@IanMcT
IanMcT / variables.py
Last active September 22, 2016 14:06
Demonstrates variables
#I McTavish
#Sept 21, 2016
#Variables - demonstrate variables
#Declare an integer variable
my_age = 17
#output my_age
print(my_age)
#output type of data
print(type(my_age))