Skip to content

Instantly share code, notes, and snippets.

View brentxphillips's full-sized avatar

Brent Phillips brentxphillips

  • Portland, Maine
View GitHub Profile
@brentxphillips
brentxphillips / return_test.py
Created July 4, 2021 19:57
Simple value returning function
# Simple value returning function
# return_test.py
def pass_info(x, y):
sum = x + y
# nested conditional testing if a new math operation changes the sum returned?
if sum < 100:
sum += 1
return sum
@brentxphillips
brentxphillips / two_images.py
Last active June 28, 2021 01:02
Displays two images side-by-side, in GraphWin
# two_images.py
# display two images
import graphicsPlus as gr
win = gr.GraphWin("Two Images", 1000, 1000)
def two_images():
# specify image to display from same directory as file, in quotes with file extension; code determines image center point and moves accordingly
image = gr.Image( gr.Point(0, 0), "flowers.ppm")
@brentxphillips
brentxphillips / square_import.py
Last active June 15, 2021 23:33
Turtle graphics test, imports shape function from a separate file and draws it
# Import test, two files, imports file and function, passes parameters and draws a shape
# main.py
import turtle as t
import shapelib as lib
def main():
lib.square1(100, 90)
@brentxphillips
brentxphillips / stacked_rectangles.py
Created May 21, 2021 19:48
Three stacked and centered rectangles
# Brent Phillips
# CS5001/5003 Summer 2021
# Lab 2
# Turtle graphics, three stacked rectangles, centered, different sizes
# Import turtle, open canvas, start location
import turtle as t
t.screensize(canvwidth = 400, canvheight = 400)
def goto(x, y):
t.up()
@brentxphillips
brentxphillips / stacked_squares_centered.py
Created May 21, 2021 19:26
Three centered stacked squares, different sizes
# Brent Phillips
# CS5001/5003 Summer 2021
# Lab 2
# Turtle graphics, three stacked squares, centered, different sizes
# Import turtle, open canvas, start location
import turtle as t
t.screensize(canvwidth = 400, canvheight = 400)
def goto(x, y):
t.up()
@brentxphillips
brentxphillips / stacked_squares.py
Last active May 21, 2021 19:18
Three stacked squares, identical size
# Brent Phillips
# CS5001/5003 Summer 2021
# Lab 2
# Turtle graphics, three identical stacked squares
# Import turtle, open canvas, start location
import turtle as t
t.screensize(canvwidth = 400, canvheight = 400)
def goto(x, y):
t.up()
@brentxphillips
brentxphillips / importfunction.py
Created March 12, 2021 06:49
Imports a function from another file and draws a circle
# Import example, imports function from a separate file
# filea.py
import graphicsPlus as gr
import fileb as x
win = gr.GraphWin("New Shapes", 800, 800)
x.shape(gr, win)
@brentxphillips
brentxphillips / quiz6.py
Created March 11, 2021 16:44
Quiz 6 code
import random
HOUSE = 0
SIZE = 1
def conflict( sideA, sideB ):
sideAleft = 0
@brentxphillips
brentxphillips / function_question.py
Last active March 11, 2021 03:38
Code with errors: How can I get info in the circle function into the drop function?
# Brent Phillips
# CS5001/5003 Spring 2021
# Project 5
# Simplied code to use for troubleshooting
# Errors:
"""
File "/Users/brentphillips/Desktop/Gist/trouble.py", line 39, in <module>
main()
File "/Users/brentphillips/Desktop/Gist/trouble.py", line 32, in main
@brentxphillips
brentxphillips / drop.py
Created March 11, 2021 02:03
Two set of balls dropping, shifting right at mid height
import graphicsPlus as gr
import time
import random
# Opens graphicsPlus window
win = gr.GraphWin("New Shapes", 800, 800)
def circles1():