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 / recursion_while.py
Created March 10, 2022 01:52
Recursion practice loop created from a while loop
# Recursion practice
# Recurion loop version of a while loop[]
triangle = ["one"]
def pyramid():
print(triangle)
triangle.append("one")
line_len = len(triangle)
@brentxphillips
brentxphillips / while_recursion.py
Last active March 10, 2022 01:50
While recursive loop version
# triangle.py
# Recurion loop practice starting with a while loop example
triangle = ["one"]
def pyramid():
while len(triangle) < 6:
line_len = len(triangle)
print(triangle)
triangle.append("one")
@brentxphillips
brentxphillips / CS5001-020122 Basic Return Exercise
Last active February 2, 2022 00:27
Simple return statements
# Class excercise
# Return statements practice
def helloworld():
print("hello world")
helloworld()
def isodd(num):
@brentxphillips
brentxphillips / texttest.py
Created August 16, 2021 16:23
Simple text block in GraphicsPlus
import graphicsPlus as gr
win = gr.GraphWin("Simple Circle", 400, 400)
def text():
textblock = gr.Text(gr.Point(100, 100), "Hello!")
textblock.setSize(18)
textblock.draw(win)
def main():
text()
@brentxphillips
brentxphillips / string_list.py
Created July 4, 2021 21:35
Prints string, letter-by-letter
# prints a string letter-by-letter
def num_letter_test(x):
string_input = x
string_len = len(string_input)
counter = 0
for i in range(string_len):
print(string_input[counter])
counter += 1
@brentxphillips
brentxphillips / return_test7.py
Created July 4, 2021 21:34
Simple return value test, multiple booleans
# Simple value returning function, with nested conditional and boolean check/return
# return_test7.py
def pass_info(x, y):
add = x + y
# added a nested condition, checking if odd or even and assigning a boolean
if (add % 2 == 0):
boo = True
elif (add % 2 == 1):
boo = False
@brentxphillips
brentxphillips / return_test5.py
Created July 4, 2021 20:39
Simple value return test, boolean test
# Simple value returning function, with nested conditional and boolean check/return
# return_test5.py
def pass_info(x, y):
add = x + y
# adding a nested condition and operation doesn't seem to impact return statement
if add < 10:
boo = False
return boo
@brentxphillips
brentxphillips / return_test4.py
Last active July 4, 2021 20:38
Simple value return function, with nested conditional
# Simple value returning function, two retunred values
# return_test4.py
def pass_info(x, y):
add = x + y
# adding a nested condition and operation doesn't seem to impact return statement
if add < 10:
add = 11
return add
@brentxphillips
brentxphillips / return_test3.py
Created July 4, 2021 20:23
Simple value returning function, two returned values
# Simple value returning function, two retunred values
# return_test3.py
def pass_info(x, y):
add = x + y
sub = x - y
# note, if one return variable is removed then the main function will only output remaining value
return add, sub
def main():
@brentxphillips
brentxphillips / return_test2.py
Created July 4, 2021 20:08
Simple value returning function with odd or even test
# Simple value returning function, plus odd or even test
# return_test2.py
def pass_info(x, y):
sum = x + y
# nested conditional testing if a new math operation changes the sum returned?
# tests if sum is even
if (sum % 2 == 0):
sum += 1
# tests if sum is odd