Tuesday, March 15, 2016

Quick Thoughts On How I Became A Programmer

Dear readers,

Quickly, I'd like to tell you how I came to be a computer programmer (with proverbial beginner status don't worry!). Basically, 5 or so years ago, I was surfing the web like anyone else, and I stumbled upon these MOOCs, we called them, these Massive Open On-line Courses.

The first MOOC I took, I think, was on the Udacity platform. I took a course that taught me Python all while building an actual, working search engine. It was a really great course. It effectively taught me how to write programs in the Python language.

Then, of course, I ended up taking over 100 different MOOCs on a variety of subjects. I wasn't happy just knowing how to write code in Python. I wanted to learn the ins and outs of Computer Science, both the Theoretical side and the Practical.

So that's what I did. Once I knew how Python worked, then I started trying to figure out what I was going to build. There comes that time, right, in the early day's of one's new life as a programmer where one must decide on some "project" of some sort.

In any case, I ended up fiddling and tinkering with all sorts of scripts, playing around with different modules and libraries in Python. I ended up playing with the Twitter Search API, feeling super amazed at what I could do with so few lines of code. It was truly an amazing experience.

Then slowly the projects started getting a little bigger in scope and in scale. I ended up writing my first real program in Python. I will take a break but will get back to the topic. Here, for your viewing pleasure, is my first ever ACTUAL PYTHON PROGRAM. And it works too! It is an implementation, in Python, of a Geomancy type reading. Look it up! (Google query: GEOMANCY).


 
import random
Mothers = [[random.choice([1,2]) for x in xrange(0,4)] for x in xrange(0,4)]
FirstDaughter = [x[0] for x in Mothers]
SecondDaughter = [x[1] for x in Mothers]
ThirdDaughter = [x[2] for x in Mothers]
FourthDaughter = [x[3] for x in Mothers]
def my_func(val):
if val == 1:
return val
if val == 0:
return val+2
def func(my_func,seq):
return [my_func(n) for n in seq]
FirstNiece = map(sum, zip(Mothers[0],Mothers[1]))
FirstNiece = [FirstNiece[i]%2 for i in range(0,len(FirstNiece))]
FirstNiece = func(my_func,FirstNiece)
SecondNiece = map(sum, zip(Mothers[2],Mothers[3]))
SecondNiece = [SecondNiece[i]%2 for i in range(0,len(SecondNiece))]
SecondNiece = func(my_func,SecondNiece)
Daughters = [FirstDaughter, SecondDaughter, ThirdDaughter, FourthDaughter]
ThirdNiece = map(sum, zip(Daughters[0],Daughters[1]))
ThirdNiece = [ThirdNiece[i]%2 for i in range(0,len(ThirdNiece))]
ThirdNiece = func(my_func,ThirdNiece)
FourthNiece = map(sum, zip(Daughters[2],Daughters[3]))
FourthNiece = [FourthNiece[i]%2 for i in range(0,len(FourthNiece))]
FourthNiece = func(my_func,FourthNiece)
Nieces = [FirstNiece, SecondNiece, ThirdNiece, FourthNiece]
FirstWitness = map(sum, zip(Nieces[0],Nieces[1]))
FirstWitness = [FirstWitness[i]%2 for i in range(0,len(FirstWitness))]
FirstWitness = func(my_func,FirstWitness)
SecondWitness = map(sum, zip(Nieces[2],Nieces[3]))
SecondWitness = [SecondWitness[i]%2 for i in range(0,len(SecondWitness))]
SecondWitness = func(my_func,SecondWitness)
Witnesses = [FirstWitness, SecondWitness]
Judge = map(sum, zip(Witnesses[0],Witnesses[1]))
Judge = [Judge[i]%2 for i in range(0,len(Judge))]
Judge = func(my_func,Judge)
Reconciler = map(sum, zip(Mothers[0],Judge))
Reconciler = [Reconciler[i]%2 for i in range(0,len(Reconciler))]
Reconciler = func(my_func,Reconciler)
def PrintShield():
print 'GEOMANTIC FIGURES OF THE SHIELD CHART:\n','Mothers = ',Mothers,'\n','Daughters = ',Daughters,'\n','Nieces = ',Nieces,'\n','Witnesses = ',Witnesses,'\n','Judge = ',Judge,'\n','Reconciler = ',Reconciler,'\n'
view raw geomancia.py hosted with ❤ by GitHub
Here is another related script I wrote in Python. This one draws a random Geomantic Figure.

import random
one = " *\n"
two = "* *\n"
def Via():
print 'Via\n\n'+one*4
def Cauda_Draconis():
print 'Cauda Draconis\n\n'+one*3+two
def Puer():
print 'Puer\n\n'+one*2+two+one
def Fortuna_Minor():
print 'Fortuna Minor\n\n'+one*2+two*2
def Puella():
print 'Puella\n\n'+one+two+one*2
def Amissio():
print 'Amissio\n\n'+(one+two)*2
def Carcer():
print 'Carcer\n\n'+one+(two*2)+one
def Laetitia():
print 'Laetitia\n\n'+one+(two*3)
def Caput_Draconis():
print 'Caput Draconis\n\n'+two+(one*3)
def Conjunctio():
print 'Conjunctio\n\n'+two+(one*2)+two
def Acquisito():
print 'Acquisito\n\n'+(two+one)*2
def Rubeus():
print 'Rubeus\n\n'+two+one+(two*2)
def Fortuna_Major():
print 'Fortuna Major\n\n'+(two*2)+(one*2)
def Albus():
print 'Albus\n\n'+(two*2)+one+two
def Tristitia():
print 'Tristitia\n\n'+(two*3)+one
def Populus():
print 'Populus\n\n'+two*4
Geomancia = [Via, Cauda_Draconis, Puer, Fortuna_Minor, Puella,
Amissio, Carcer, Laetitia, Caput_Draconis, Conjunctio, Acquisito,
Rubeus, Fortuna_Major, Albus, Tristitia, Populus]
def digit():
return 8*(random.randint(0,1))+4*(random.randint(0,1))+2*(random.randint(0,1))+1*(random.randint(0,1))
def Draw():
Geomancia[digit()]()
"""
Usage:
>>> Draw()
Caput Draconis
* *
*
*
*
"""
view raw geomancia_v1.py hosted with ❤ by GitHub

No comments:

Post a Comment