# Fibonacci sequence generator

Here’s an early version of a fibonacci sequence generator which includes a simple turtle drawing of results as a spiral (have #ed out a set of instructions which can draw the fibonacci squares.

It’s by no means perfect (still produces a turtle window with no drawing in it if I select n) but it was a fun half an hour figuring it out.

```from turtle import *
loop = True

try:
while loop == True:
print("\n")
print("Enter fibonacci start values and length of sequence (q to quit)")
start1 = int(input("Enter value 1:"))
start2 = int(input("Enter value 2:"))
sequence = int(input("How many fibonnaci values (minimum 3):"))
graphq = input("Do you want to create a graph? (y/n):")
sequence = sequence - 2
fibonacci = []
a = start1
b = start2
fibonacci.append(a)
fibonacci.append(b)
for i in range (sequence):
c = a+b
fibonacci.append(c)
a = b
b = c
if graphq == "y" or graphq == "Y":
print ("printing sequence and graph")
print(fibonacci)
title("Fibonacci sequence")
setup(500,500,150,150)
for i in range (len(fibonacci)):
circle(fibonacci[i],90)
#squares - uncomment this and comment out circle
## for j in range(4):
## forward(fibonacci[i])
## right(90)
## right(90)
## forward(fibonacci[i])
## left(90)
## forward(fibonacci[i])
## left(90)
else:
print ("printing sequence only")
print(fibonacci)

exitonclick()
except ValueError:
loop = False
print("quitting")

```

# mucking around in #sonicpi

I should be sleeping – instead I am mucking around in sonic pi

```
use_synth :fm
use_bpm 120
with_fx :distortion do
20.times do
sample :drum_cymbal_closed
play 55, amp: 1.5, pan: -1, release: 0.2
sleep sample_duration(:drum_cymbal_closed)
sample :drum_heavy_kick, pan: -1
sleep 0.3
sample :elec_blip, rate: 0.5
sleep 0.5
end
end

```

# Error message using os module #Python

Currently working on a small personal project.  Aim is to try and see whether I can use turtle graphics to automatically generate a set of frames for a Vine video.  The script currently produces some nice .eps images which I am using Photoshop to batch process to .jpg.  The logical next step is to see if i can convert the EPS files to jpg within the script.

A very nice chap by the name of Trevor Appleton helped me on twitter by providing the following function

```
def tiff2jpg(): ### Convert .tiff files to .jpg - function from @trevorappleton

openFiles = glob.glob('*.eps')
for files in openFiles:

inFile = Image.open(files)
fileName = os.path.splitext(files)[0] # gets filename
outFile = fileName + &amp;quot;.jpg&amp;quot;
inFile.save(outFile)

return()

```

Here is the full script on github.

But unfortunately it spits out the following error message

`Traceback (most recent call last):<br /> File "/Users/sharland/Dropbox/computing_department/Languages and Systems/python/python_scripts/vine_animations/starburst_pulse.py", line 62, in &lt;module&gt;<br /> tiff2jpg()<br /> File "/Users/sharland/Dropbox/computing_department/Languages and Systems/python/python_scripts/vine_animations/starburst_pulse.py", line 35, in tiff2jpg<br /> inFile.save(outFile)<br /> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/Image.py", line 1631, in save<br /> self.load()<br /> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/EpsImagePlugin.py", line 361, in load<br /> self.im = Ghostscript(self.tile, self.size, self.fp, scale)<br /> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PIL/EpsImagePlugin.py", line 130, in Ghostscript<br /> gs = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)<br /> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 848, in __init__<br /> restore_signals, start_new_session)<br /> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1441, in _execute_child<br /> raise child_exception_type(errno_num, err_msg)<br />FileNotFoundError: [Errno 2] No such file or directory: 'gs'`

# #Python and the #Pibrella – getting started #raspberrypi

Apologies for the hashtag abuse in the title – it works …

So recently I bought a Pibrella!  I figured it would be a good time now that my confidence is growing with the Raspberry Pi  to explore the concept of the GPIO breakout board.  I saw one back at BETT without clocking that it required soldering (I didn’t buy) and as I have a lot to learn, and didn’t want to add soldering to a burgeoning list, I ignored that board until recently when I saw a tweet about the Pibrella and bought one within about 5 minutes of reading the tweet.  It helps that it’s backed by Pimoroni (who are awesome – disclosure I am in no way paid by them!).

Getting it setup was … interesting … and not helped by sitting behind a school proxy server.  Now I know some might say that perhaps I should just set it up at home but I eventually would like pupils to use them and obviously therefore set them up.  So after a huge amount of help from Phil Howard (@gadgetoid) to whom I am immensely grateful I was eventually able to achieve …

My next thought was how I could use this now with a class. After finally wrestling git into submission I now have a repo where I am going to stash ALL of my python scripts (may break this up at a later stage). Inside that I have setup a pibrella folder where I am going to add scripts I write or find which work really well with the pibrella.

As an example here’s a very simple one I’ve written:

```import pibrella
import time

print("Red light is on!")
pibrella.light.red.on()
time.sleep(2)

print("Amber light is on!")
pibrella.light.amber.on()
time.sleep(2)

print("Green light is on!")
pibrella.light.green.on()
time.sleep(2)
```

This is going to be fun!

# Coding a factorial script in #python #code365

Although I’ve given up on my idea of trying to blog about coding and programming every day this year (what was I thinking? too much left over christmas ‘spirits’! :-)) I will still be using this blog as my pure computing, programming etc writing platform.

I’m still working through Mark Clarkson’s Introduction to Python book and I’ve got up to some of the first challenges which I need to code myself rather than use pre-written examples.  This one was a challenge to write a script to work out the factorial of a number.    Even though I can’t even remember doing factorials at school it’s an easy concept to pick up.

The script wasn’t though as my general Maths skills are shocking (I passed Maths in high school in South Africa on our equivalent of foundation entry and only after extensive tuition – doesn’t bode well for programming).  After a suitable hint I managed to figure this one out.

currentNumber = int(input(“Input integer: “))
runningTotal = currentNumber

while currentNumber > 0:

currentNumber = currentNumber – 1
runningTotal = currentNumber * runningTotal
print(runningTotal)

It works but the output gives succeeding results until it hits the right factorial.  This to me doesn’t seem ‘clean’ and so a further consideration might be to see if it only returns the factorial result as the output.

PS: If anyone has a better way of showing indents in a wordpress blog I wouldn’t mind some suggestions!

# How are you promoting #computing in your school? #code365

In all this work which a lot of people I know are putting into getting ready I am wondering how people are promoting computing in their schools.  I work at an all-girls school which I initially thought would be a hindrance to getting pupils interested but which actually may be a benefit simply due to the lack of ‘pimply’ boys dominating a computing class.

So I have been promoting computing through the following means

• a simple computer club where we have been doing basic Python
• having a copy or two of the GCSE textbook to loan to pupils
• a possible visit to TNMOC is being planned
• not much else!

But I may have at least 6 girls interested so far which is very good.  But I am keen to know how other staff who don’t currently run computing might be promoting it to their pupils so I could nick a few ideas?

# Digital Literacy and computing #code365

I was going to do another python script today but after a short discussion with @bobharrisonset about a digital literacy workshop I thought I should jot down a few ideas.

The first point about digital literacy I always make is that there is no firm definition as what digital literacy is.  Doug Belshaw breaks it up into 8 separate elements which are all perfectly reasonable but in the end it kind of over-complicates what should be a simple issue.

I like the Wikipedia definition the best:

Digital literacy is the ability to effectively and critically navigate, evaluate and create information using a range of digital technologies. It requires one “to recognize and use that power, to manipulate and transform digital media, to distribute pervasively, and to easily adapt them to new forms”.  Digital literacy does not replace traditional forms of literacy, it builds upon the foundation of traditional forms of literacy.

I especially  like the first part because it shows that Digital Literacy isn’t about learning how to do a mail merge but about the fact that knowing how to mail merge gives one the ability to critically navigate information and ‘adapt it to new forms’.

When originally developing #digitalstudies (which is still ongoing!) I originally made the mistake of thinking that we need to signpost and make a big deal of teaching DIGiTAL LITERACY because everyone talks about it and therefore it’s important.  I think digital literacy is important but it shouldn’t necessaily be front and centre to all teaching plans.

My point therefore is – if a teacher is teaching a set of pupils how to effectively research a topic on the Internet or teaching them an effective systems development process when building a database they are teaching them good digital literacy already.  They key though comes back to how the pupils are measured in their progress.  Last year when I met with some business people they all talked about pupils having a good level of competencies rather than skills when they come into business.  ICT teachers I feel should therefore develop their own set of competencies which pupils could be measured against (or use a consistent set which a number of other schools use).

With regard to computing this therefore means that computing which is a competency can then be built into the range of competencies one uses to assess pupils.  This keeps it from becoming too dominant in the classroom at the expense of other competencies in the classroom.

The bottom line therefore is – don’t make a big deal about digital literacy in front of pupils.  Teach them using effective group and project work about all sorts of interesting and engaging activities ranging from programming through to information management and digital creativity but then assess them against a set of competencies which can demonstrate how their digital literacy is improving.

Looking at the set of #digitalstudies competencies I developed a while back I think I’ll go back and re-assess them, re-build and then re-post here hopefully soon.