I mentioned before in my blog that I do not yet have any formal collegiate training in any programming language. This semester at the community college I took my first programming class which is simply a course in programming logic that works mainly in pseudocode. Apparently flowcharts are so out of date that I’m a relic for using them, as if I wasn’t enough of a relic for remembering my father trying to program his dang Times Sinclair computer when I was a child.
However, since pseudocode by it’s very nature cannot be made to pass the “does it work” test I’ve tried to self-teach two languages to myself during the course of this class: first, JustBASIC and now Python 3.x. I was doing some research on computer languages early in the term to see what it might be useful for me to take in future semesters, and found out Python was made language of the year by the TIOBE index, twice (2007 & 2010). Also, as I have mentioned in another post the Panda 3D game engine works with a combination of Python and C++
Well, to get a grasp of programming in Python I went to MIT opencourseware and downloaded the .pdf of the text book they are using, “How to Think Like a Computer Scientist.” (Ah, open course ware – knowledge free for the sake of knowledge.) I also translated my homework assignments that had been completed in JustBASIC into Python. I was using Python 3.13 and then I downloaded “Portable Python” which is supposed to be able to run off a memory stick or USB flash drive and came with the PyScripter IDE, so that is what I am currently using. (Can somebody come out with a newer version for Python 3.2 please?)
Anyway, doing this gave me the following programs:
in JustBASIC -
REM Program To Display Student Data
REM LIAM BOYLE
REM 15 FEB 2011
REM Variable Declarations
REM IDNumber num
REM FirstName$ string
REM LastName$ string
REM Major$ string
REM GPA num
print “Enter ID, FirstName, LastName, Major and GPA…”
Input IDNumber
Input FirstName$
Input LastName$
Input Major$
Input GPA
If GPA <= 2.0 then
print IDNumber
Print FirstName$
Print LastName$
Print Major$
Print GPA
else
REM don’t print
end if
In Python 3.x –
#Program To Display Student Data
#Assignment 4 part a #in Python 3.x#
#Liam Boyle
#03 Apr 2011
#Variable Declarations
#IDNumber integer
#FirstName string
#LastName string
#Major$ string
#GPA float
prompt = “Enter ID number”
IDNumber = input(prompt)
prompt = “Enter first name”
FirstName = input(prompt)
prompt = “Enter last name”
LastName = input(prompt)
prompt = “Enter major course of study”
Major = input(prompt)
prompt = “Enter Grade Point Average”
GPA = input(prompt)
GPA = float(GPA)
if GPA <= 2.0:
print (IDNumber)
print (FirstName)
print (LastName)
print (Major)
print (GPA)
In JustBASIC –
REM Program To Display Student Data
REM LIAM BOYLE
REM 15 FEB 2011
REM Variable Declarations
REM IDNumber num
REM FirstName$ string
REM LastName$ string
REM Major$ string
REM GPA num
REM ContinueAns$ string
Let ContinueAns$ = “Y”
While ContinueAns$ = “Y”
Print “Enter ID, FirstName, LastName, Major and GPA…”
Input IDNumber
Input FirstName$
Input LastName$
Input Major$
Input GPA
If GPA < 2.0 then
print IDNumber
Print FirstName$
Print LastName$
Print Major$
Print GPA
End If
Print “Do you want to Continue Y/N”
Input ContinueAns$
Wend
In Python 3.x –
#Program To Display Student Data
#Assignment 4 part b #in Python 3.x#
#Liam Boyle
#03 Apr 2011
#Variable Declarations
#IDNumber integer
#FirstName string
#LastName string
#Major$ string
#GPA float
ContinueAns = “y”
while ContinueAns == “y”:
prompt = “Enter ID number\n”
IDNumber = input(prompt)
prompt = “Enter first name\n”
FirstName = input(prompt)
prompt = “Enter last name\n”
LastName = input(prompt)
prompt = “Enter major course of study\n”
Major = input(prompt)
prompt = “Enter Grade Point Average\n”
GPA = input(prompt)
GPA = float(GPA)
#————-
if GPA <= 2.0:
print (IDNumber)
print (FirstName)
print (LastName)
print (Major)
print (GPA)
prompt = “Do you want to continue y/n \n”
ContinueAns = input(prompt)
In JustBASIC –
REM Program To Display Student Data
REM LIAM BOYLE
REM 15 FEB 2011
REM Variable Declarations
REM IDNumber num
REM FirstName$ string
REM LastName$ string
REM Major$ string
REM GPA num
Print “Enter ID, FirstName, LastName, Major and GPA…”
Input IDNumber
While IDNumber > 0
Input FirstName$
Input LastName$
Input Major$
Input GPA
If GPA < 2.000 then
Print “Under 2.0″
Print IDNumber
Print FirstName$
Print LastName$
Print Major$
Print GPA
Else
If GPA >= 3.5 and Major$ = “English” then
Print “Literary Honors Society”
Print IDNumber
Print FirstName$
Print LastName$
Print Major$
Print GPA
End If
End If
Print “Enter ID, FirstName, LastName, Major and GPA…”
Input IDNumber
Wend
In Python 3.x -
#Program To Display Student Data
#Assignment 4 part b #in Python 3.x
#Liam Boyle
#03 Apr 2011
#Variable Declarations
#IDNumber integer
#FirstName string
#LastName string
#Major$ string
#GPA float
ContinueAns = “y”
while ContinueAns == “y”:
prompt = “Enter ID number\n”
IDNumber = input(prompt)
prompt = “Enter first name\n”
FirstName = input(prompt)
prompt = “Enter last name\n”
LastName = input(prompt)
prompt = “Enter major course of study\n”
Major = input(prompt)
prompt = “Enter Grade Point Average\n”
GPA = input(prompt)
GPA = float(GPA)
#————-
if GPA <= 2.0:
print (IDNumber)
print (FirstName)
print (LastName)
print (Major)
print (GPA)
else:
if GPA >= 3.5 and Major == “English”:
print (“Literary Honors Society”)
print (IDNumber)
print (FirstName)
print (LastName)
print (Major)
print (GPA)
prompt = “Do you want to continue y/n \n”
ContinueAns = input(prompt)
In JustBASIC -
REM Program for outputting even numbers from 2 to 30
REM Liam Boyle
REM CIS 120
REM Declaration
REM VariableNumber Integer
For VariableNumber = 2 to 30 step 2
Print VariableNumber
Next VariableNumber
End
In Python 3.x -
for varNum in range(2,32,2):
print(varNum)
In JustBASIC -
‘ Assignment 8, Bubble Sort
‘ Liam Boyle
‘ CIS 120
‘ 4/3/11
‘ Mainline
gosub [Housekeeping]
gosub [SortRoutine]
gosub [MeanCalculation]
gosub [MedianCalculation]
gosub [Cleanup]
end
‘——————————-
[Housekeeping]
Print “How many values do you need to enter?”
Input ListElements
Dim sortvalues(ListElements)
Let LastElement = ListElements – 1
cls
For x = 0 to LastElement
print “Enter a value to sort”
input value
sortvalues(x) = value
next
print “UnSorted List”
for x = 0 to LastElement
print sortvalues(x)
next
return
‘——————————-
[SortRoutine]
Let x = 0
Let ValuesSwitched$ = “y”
While ValuesSwitched$ = “y”
Let ValuesSwitched$ = “n”
For x = 1 to LastElement
if sortvalues(x) < sortvalues(x-1) then
gosub [SwitchValues]
end if
Next
Wend
return
‘——————————-
[MeanCalculation]
MeanValue = 0
For count = 0 to x
MeanValue = MeanValue + sortvalues(count)
Next count
MeanValue = MeanValue/(count+1)
return
‘——————————-
[MedianCalculation]
Let MedianCount = Int(LastElement/2)
If LastElement/2 = MedianCount Then
Let MedianValue = sortvalues(LastElement/2)
Else
Let MedianCount = Int(LastElement/2)
Let MedianValue = (sortvalues(MedianCount) + sortvalues(MedianCount+1))/2
End If
Return
‘——————————-
[SwitchValues]
let temp = sortvalues(x-1)
let sortvalues(x-1) = sortvalues(x)
let sortvalues(x) = temp
let ValuesSwitched$ = “y”
Return
‘——————————-
[Cleanup]
print “Sorted List”
for x = 0 to LastElement
print sortvalues(x)
next
print “Mean Value is:”, MeanValue
print “Median Value is:”, MedianValue
return
In Python 3.x -
#CIS 120 Assignment 8 in Python
#Liam Boyle
# 03 Apr 2011
#populate list
prompt = “How many values do you need to enter?”
ListElements = input(prompt)
ListElements = int(ListElements)
value = []
for x in range(0,ListElements):
prompt = “Enter a value to sort\n”
value.append(input(prompt))
value[x] = int(value[x])
print (“Unsorted List”)
for x in range(0,len(value)):
print (value[x])
#List sorting
x = 0
ValuesSwitched = “y”
while ValuesSwitched == “y”:
ValuesSwitched = “n”
for x in range(1,len(value)):
if value[x] < value[x-1]:
value[x-1], value[x] = value[x], value[x-1]
ValuesSwitched = “y”
#Mean Calculation
MeanValue = 0
for count in range(0, len(value)):
MeanValue = MeanValue + value[count]
MeanValue = MeanValue/(count)
#Median Calculation
if len(value)%2 != 0:
MedianValue = value[len(value)//2]
else:
MedianCount = (len(value)//2)
MedianValue = (value[MedianCount] + value[MedianCount+1])/2
#printing sorted list
print(“Sorted List”)
for x in range(0,len(value)):
print(value[x])
print (“Mean value is: “, MeanValue)
print (“Median value is: “, MedianValue)
The next assignment was directly written in Python 3.x without my having written a JustBASIC version.
#CIS 120 Assignment 9 part a & b combined in Python 3.x
#Liam Boyle
#4/10/2011
#Global Variable Initializations
Num1 = 0.0
Num2 = 0.0
prodnum = 0.0
#————-
def summation(x, y):
sumnums = x + y
print(“the sum of “, x, “and “, y, “is: “, sumnums)
return
#————-
def difference(x, y):
if x > y:
diffnums = x – y
print(“the difference of “, x, “and “, y, “is: “, diffnums)
else:
diffnums = y – x
print(“the difference of “, y, “and “, x, “is: “, diffnums)
return
#————-
def productof(x, y):
#global prodnum #making the answer a global variable
prodnum = x*y
return prodnum
#————-
#Main
#Start
prompt = “Please Enter Your first number: ”
Num1 = input(prompt)
Num1 = float(Num1)
prompt = “Please Enter Your second number: ”
Num2 = input(prompt)
Num2 = float(Num2)
summation(Num1, Num2)
difference(Num1, Num2)
#productof(Num1, Num2)
print(“The product of “, Num1, “and “, Num2, “is: “, productof(Num1, Num2))
#End
This in turn led to my standard first non-assignment project for any programming language, of which the JustBASIC version was published in an earlier blog:
#Universal Theosophic Reduction Calculator
#Liam Boyle
#04/09/11
#————-
##def DoublingIteration(): #This was part of the original JustBASIC program
## global NumValue #designating global list
## prompt = “enter the total number of doubling iterations\n”
## iterationNum = input(prompt)
## iterationNum = int(iterationNum)
## for Iteration in range(1,iterationNum,1):
## NumValue.append(NumValue[Iteration - 1] * 2**Iteration)
## #print(NumValue[Iteration]) #scaffolding for development
## return
#————-
def IntegerTheosophicReductionCalculator():
TempTheoReducValue = 0
prompt = “enter integer value to be reduced \n”
NumValue = input(prompt)
NumValue = int(NumValue)
if NumValue <= 9:
TheoReducValue = NumValue
else:
NumValueString = str(NumValue)
for SubChar in NumValueString:
TempTheoReducValue = TempTheoReducValue + int(SubChar)
while TempTheoReducValue > 9:
TempTheoReducValueString = “”
TempTheoReducValueString = str(TempTheoReducValue)
TempTheoReducValue = 0
for SubCharB in TempTheoReducValueString:
TempTheoReducValue = TempTheoReducValue + int(SubCharB)
TheoReducValue = TempTheoReducValue
print(NumValue,”\t”,TheoReducValue)
return
#————-
def StringTheosophicReductionCalculator():
TempTheoReducValue = 0
prompt = “Enter term to be philosophically reduced\n”
EntryString = input(prompt)
EntryString = EntryString.lower()
#print(EntryString) #scaffolding for development
for char in EntryString:
if char == “a” or “j” or “s”:
TempTheoReducValue = TempTheoReducValue + 1
elif char == “b” or “k” or “t”:
TempTheoReducValue = TempTheoReducValue + 2
elif char == “c” or “l” or “u”:
TempTheoReducValue = TempTheoReducValue + 3
elif char == “d” or “m” or “v”:
TempTheoReducValue = TempTheoReducValue + 4
elif char == “e” or “n” or “w”:
TempTheoReducValue = TempTheoReducValue + 5
elif char == “f” or “o” or “x”:
TempTheoReducValue = TempTheoReducValue + 6
elif char == “g” or “p” or “y”:
TempTheoReducValue = TempTheoReducValue + 7
elif char == “h” or “q” or “z”:
TempTheoReducValue = TempTheoReducValue + 8
elif char == “i” or “r”:
TempTheoReducValue = TempTheoReducValue + 9
elif char == “1″or”2″or”3″or”4″or”5″or”6″or”7″or”8″or”9″:
TempTheoReducValue = TempTheoReducValue + int(char)
else:
TempTheoReducValue = TempTheoReducValue + 0
while TempTheoReducValue > 9:
TempTheoReducValueString = “”
TempTheoReducValueString = str(TempTheoReducValue)
TempTheoReducValue = 0
for SubCharB in TempTheoReducValueString:
TempTheoReducValue = TempTheoReducValue + int(SubCharB)
TheoReducValue = TempTheoReducValue
print(EntryString,”\t”,TheoReducValue)
return
#————-
def opener():
print(“Universal Theosophic Reduction Calculator for Vortex Mathematics”)
prompt = “do you have an integer value to be reduced? y/n \n”
questionAns = input(prompt)
if questionAns == “y”:
IntegerTheosophicReductionCalculator()
prompt = “Do you have an alphanumeric term to be reduced y/n \n”
questionAns = input(prompt)
if questionAns == “y”:
StringTheosophicReductionCalculator()
return
#————-
def continueQues():
prompt = “Do you want to run again y/n?\n”
ContinueAns = input(prompt)
if ContinueAns == “y”:
opener()
return
#————-
#Main
opener()
continueQues()
#End
So where does all this lead, and what does it have to do with gamification? Well, to me building programming skill is the nuts and bolts of how to gamify life, and the world. I’m not all that outgoing I’m limited in how physically active I can be, but this I can do. I will be the first to admit that these are all beginner level command line programs but this is the beginning of the path I need to walk (well, limp along – literally, I walk with a cane folks) to achieve the end of bringing game techniques to life. My goal is to do this by bringing the real world into the game. By making games that can reflect reality absolutely.
Liam B