Connected


Once, atoms were sparsely connected
 then they connected.
Once, molecules were sparsely connected
 then they connected.
Once, proteins were sparsely connected
 then they connected.
Once, cells were sparsely connected
 then they connected.
Once, people were sparsely connected
 then they connected.
Once, societies and countries were sparsely connected
 then they connected.
Once, technologies were sparsely connected
 then they connected.
Once, people were sparsely connected

Learning Programming?

The poem above was written with a bit of python code. I’m sure you spotted the repetition. Can you isolate the changing vs non-changing portions of the poem?

My favorite way to learn programming is to puzzle through the code. Figure out what it’s doing. Change how it works. Mess it up. Make it better.

Here’s the code for this poem. Make sure you mess with it.  Click here to try this poem

 

# you can make functions with def in python
# this function is named makeVerseOne
# it has one parameter, named 'what'
# the function outpus a a verse with {0} replaced with the parameter 'what'
def makeVerseOne(what):
  return "Once, {0} were sparsely connected".format(what)
  
  
# this does the same thing but with a different verse
def makeVerseTwo(became):
  return " then they {0}.".format(became)
  
# this is a list of things my poem is about  
whatWas = [
  "atoms",
  "molecules",
  "proteins",
  "cells",
  "people",
  "societies and countries",
  "technologies",
  "people"
]


# this is an empty list. I want to STORE my verses here.
verses = []

# we commonly fill lists with values returned from functions
for what in whatWas :
  verses.append(makeVerseOne(what))
  verses.append(makeVerseTwo("connected"))
  
# remove last line, for edginess
verses.pop()
  
# lets combine all the verses with a newline after each verse
poem = "\n".join(verses)

# output the poem to the terminal
print(poem)