tears = 1
tears+=1
print(tears)
5
...consider that the source code from the Apollo Guidance Computer’s software has routines that programmer Don Eyles referred to using the names of characters from Hamlet, Rosencrantz and Guildenstern (Dobson and Mosteirin 2019). Many computer programs found “in the wild” make different historical, literary, and film references, among other sorts of references. Computer programs are cultural artifacts, so why shouldn’t they make such references?
def double(sequence):
result = []
for element in sequence:
result = result + [element * 2]
return result
words = ['sweet', 'dreams', 'are', 'made', 'of', tears, 'tears']
double(words)
['sweetsweet', 'dreamsdreams', 'areare', 'mademade', 'ofof', 14, 'tearstears']
tears+=1
double([0, 2, 3])
[0, 4, 6]
double([0, 'eheh', 2])
[0, 'eheheheh', 4]
Consider a person who truly has no expectation at all of what is going to happen upon entering:
double([4,8,15,16,23,42])
[8, 16, 30, 32, 46, 84]
The computer might as well output 17, or display the message “Hello, world,” or play Rick Astley’s music video “Never Gonna Give You Up.”
double('tears')
['tt', 'ee', 'aa', 'rr', 'ss']
eheh
double(double('tears'))
['tttt', 'eeee', 'aaaa', 'rrrr', 'ssss']
double(double(double('tears')))
['tttttttt', 'eeeeeeee', 'aaaaaaaa', 'rrrrrrrr', 'ssssssss']
def sub(sequence):
result = []
for element in sequence:
result = result + sequence + [element]
return result
sub(['piza', 'mandollino', 'mama'])
['piza', 'mandollino', 'mama', 'piza', 'piza', 'mandollino', 'mama', 'mandollino', 'piza', 'mandollino', 'mama', 'mama']
oh no ok this was valid but not really intentional
data = 'lorem ipsum dolor'
data[:3]
'lor'
i like how do you add something to an array in python
[1,2,3] + [4]
[1, 2, 3, 4]
def bobble(sequence):
result = []
for element in sequence:
result = result + [element[:2] * 3 + element]
return result
bobble(['ora', 'et', 'colora'])
['orororora', 'etetetet', 'cocococolora']
bobble([1,2,3,'stella'])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_1958/3302526242.py in <module> ----> 1 bobble([1,2,3,'stella']) /tmp/ipykernel_1958/2751587917.py in bobble(sequence) 2 result = [] 3 for element in sequence: ----> 4 result = result + [element[:2] * 3 + element] 5 return result TypeError: 'int' object is not subscriptable
in order to achieve something one has to give up on something else
in this case: integers
bobble('in order to achieve something one has to give up on something else')
['iiii', 'nnnn', ' ', 'oooo', 'rrrr', 'dddd', 'eeee', 'rrrr', ' ', 'tttt', 'oooo', ' ', 'aaaa', 'cccc', 'hhhh', 'iiii', 'eeee', 'vvvv', 'eeee', ' ', 'ssss', 'oooo', 'mmmm', 'eeee', 'tttt', 'hhhh', 'iiii', 'nnnn', 'gggg', ' ', 'oooo', 'nnnn', 'eeee', ' ', 'hhhh', 'aaaa', 'ssss', ' ', 'tttt', 'oooo', ' ', 'gggg', 'iiii', 'vvvv', 'eeee', ' ', 'uuuu', 'pppp', ' ', 'oooo', 'nnnn', ' ', 'ssss', 'oooo', 'mmmm', 'eeee', 'tttt', 'hhhh', 'iiii', 'nnnn', 'gggg', ' ', 'eeee', 'llll', 'ssss', 'eeee']
# free 6.1
from random import random
probability = 0.2
def babble(sequence):
result = []
for element in sequence:
if random() < probability and element != ' ':
element = (element[:2]+'-') * 2 + element
result = result + [element]
return result
# https://docs.python.org/3/library/stdtypes.html#str.join
hello = ''
hello.join(babble('in order to achieve something one has to give up on something else'))
'in-n-n orde-e-er to ach-h-hie-e-eve s-s-somet-t-thin-n-ng on-n-ne has-s-s to give u-u-up on somet-t-th-h-hing else-e-e'
# 6.1
def half(sequence):
result = []
for element in sequence:
if type(element) == str:
#if string extract the first half of the word
element = element[:round(len(element)/2)]
else:
#else just multiply 0.5 times
element = element * 0.5
result = result + [element]
return result
half([1,4,'snail', 10, 'ryanair'])
[0.5, 2.0, 'sn', 5.0, 'ryan']
# 6.2
def exclamation(sequence):
result = []
for element in sequence:
element = str(element) + '!'
result = result + [element]
return result
exclamation(['snake', 'plane', 'party', 13, 'byos'])
['snake!', 'plane!', 'party!', '13!', 'byos!']
# free 6.1 bis
# text field forever
from random import random
def field(flora, fauna):
vegetation = flora * 5
for x in range(2):
for animal in fauna:
position = round(random() * len(vegetation))
vegetation = vegetation[:position] + animal + vegetation[position:]
print(vegetation)
field('🌱🌼🌱🌿🌱🌿', '🐸🐊🐢')
🌱🌼🌱🌿🌱🌿🌱🐸🌼🌱🌿🌱🌿🌱🌼🐸🌱🌿🌱🌿🐢🌱🐊🌼🌱🌿🌱🌿🌱🐊🌼🌱🌿🌱🐢🌿
field('.,.,.,', '🐸🐢')
.,.,.,.🐢,.🐸🐢,.,.,.,.,.,.,.,🐸.,.,.,
field('__...__.__.', '🐸🐢')
field('.__.__..__', '🐸🐢')
field('__.__.__....', '🐸🐢')
__..._🐸_.__.__...__.__.__...__.__.__...🐢__._🐢_.__...__🐸.__. .__.__..__.🐸__.__.._🐢🐢_.__.__..__.__.__..__🐸.__.__..__ __.__.__....🐢__.__.__....__.__.__....🐢__.__.__....__.__.__...🐸.🐸
# free 6.1 tris
# text field forever but better
from random import random
def textField(flora, grow, fauna, puppies):
vegetation = flora * grow
for x in range(puppies):
for animal in fauna:
position = round(random() * len(vegetation))
vegetation = vegetation[:position] + animal + vegetation[position:]
print(vegetation)
text = "I was expecting something quite different from this book. Not knowing much about Ellen Ullman and going simply from the blurbs, I thought this would be the kind of optimistic corporate memoir that sets a person up nicely for a career as a management consultant or a high-powered executive role. (I have no idea why I thought this; I guess I don’t actually read a lot of this kind of thing?) But it was a pleasant surprise to find that this is pretty much the polar opposite: a highly personal, wide-ranging and often quite abstract account of what it was like to be working with complex systems at a particularly interesting time for computer stuff."
textField(text, 1, '🍏🍎🍐🍊🍋🍌🍉', 5)
I was expecting so🍎me🍉🍐t🍊hing quite diffe🍌rent from this book. Not knowing much about Ellen Ullman an🍐🍐d going simply from the blurbs, I thought this woul🍏d be the kind🍋 of optimistic corporate memoir that s🍊ets a 🍌person up nicely for a care🍎er as a management consulta🍊🍉nt or a hi🍉gh-powered executiv🍐e role. (I have no idea why I thou🍌ght this; I guess I d🍎on’t🍎 actually read a lot of this kind of thing?) But it was a pl🍌easant 🍐surprise to find that this 🍎is pretty much the polar oppo🍏site: 🍉a highly personal, wide-ranging and often q🍊🍋uite abs🍏tract acc🍋🍊ount🍏 o🍌f what 🍏it was like to be working wit🍋h complex sy🍋stems at a particularly interesting time 🍉for computer stuff.