Cryptography #iGCSE #ComputerScience

One of the nice and not-so-nice things about vague arrangements documents is that you have to work out how to best fill the gap.

Encryption methods are part of the Computer Security section of the course – symmetric and asymmetric encryption to be exact – and, while I could simply put two slides up on the screen and move on, I saw this as an opportunity to break away from exam style questions and have a little bit of practical fun with the students.

I introduced my Year 10 students to the Caesar cipher this week, surprised that very few of them had even heard of it. They caught on quickly though and were soon manually translating coded messages back into plaintext.

But as the lesson progressed the messages got longer and the students began to find translation very time consuming. So, after a bit of discussion, we decided it might be best to ask a computer to do the translation for us. We would still provide the ciper-text and shift key, and it would do the rest.

This allowed us (imagine that) to then recap on relevant pre-defined functions to translate characters into ASCII codes and then build an algorithm to apply the shift key to these ASCII codes. Once the codes were converted back to characters they were ready to display on the screen! Most students managed to get to this point, with some even working on alternatives (more on that later).

The next day the students returned and were given a tougher challenge: decryption without the shift key! We discussed the letter frequency graph shown above and tried to create an algorithm to accurately calculate the shift key.

The open-endedness of this task challenged everyone and the variety of solutions suggested touched on some of the actual decryption methods utilised.

A few students suggested a brute force decryption of a digest of the entire message, looking for a small number of short English words before comparing the calculated shift key to the frequency analysis graph. When challenged further they explained that this would decrease the processing time of the decryption algorithm as it wouldn’t have to translate as many characters. Some students had even had researched further to find out which were the most used English words in written text!

The students rounded off the lesson by creating a list of advantages and disadvantages of symmetric encryption. While students took longer on the concepts it gave them the opportunity to understand some of the ideas and issues with this type of encryption.

Next week we tackle asymmetric encryption. I can’t wait!

Social media generated art in Python #ThisIsMyClassroom #Programming #STEAM

Social media generated art in Python #ThisIsMyClassroom #Programming #STEAM

For the third blog post on this topic I wanted to use Python to generate different pieces of art without relying entirely on the random function. I decided to use the tweepy library, mainly because I had already used it to post content to Twitter but had never investigated how it could be used to read information back from Twitter.

It didn’t take long to find out how to read the latest 10 tweets from my own timeline using Python. Then I split the individual words into a list and sorted them into alphabetical order (for no real reason at the moment, but frequency analysis will follow!). Then I used the write method from the Turtle graphics library to place each word at a random location on the screen. This was my first attempt:

Screen Shot 2016-04-03 at 23.50.08

A bit tricky to read the words I thought. And I’d accidentally forgotten to penup before moving the turtle. However this accidental vector spider web became part of the artwork (because when I removed it, it looked quite boring).

A little while later I was able to change the font size at random (I changed the font to palatino after experimenting with a few others) and changing the pencolor in the same way as previous Python art programs changed the text colour too.

Screen Shot 2016-04-03 at 23.53.35

I had a lot of text to display, even just from 10 tweets, so I thought of ways to reduce the amount. I wrote a little Python subroutine that removed hashtags, mentions and URLs (as well as any other non ASCII text) and that was enough!

The video below shows the program in action. I decided to make a video this time because you can make out the individual words much more clearly at the beginning of the drawing than at the end!

As before the code is now on github (with my tweepy details removed for security). I’ve left in a commented out section of code that allows you to run a search for a keyword, hashtag or phrase instead of taking the latest timeline so you can experiment.

Any comments or improvements would be much appreciated!

SOUND GENERATED ART IN PYTHON #THISISMYCLASSROOM #PROGRAMMING #STEAM

SOUND GENERATED ART IN PYTHON #THISISMYCLASSROOM #PROGRAMMING #STEAM

I had a lot of fun experimenting with the subroutines and Python Turtle methods yesterday but wanted to push it a little further and find out if I could make use of a new Python library to help create automated art.

Somehow I’ve never built a program that utilises and analyses audio before, so challenged myself to find out more about libraries such as PyAudio and Wave this afternoon. My daughter was practising piano in the other room so it gave me a push to integrate live audio into my solution, rather than rely on pre-recorded wav files.

I learned about numpy a little this afternoon too. I hadn’t realised it had functions to extract the frequency from an audio block (FFT). The more I explore Python, the more I fall in love with it as a language!

Once I’d successfully extracted numeric frequencies from the 5 second wave file into a list I looped through them and attempted to place shapes on the Python Turtle screen to correlate with the current frequency. I decided on a simple X axis plot to begin with but then, as I realised the range between min and max frequencies usually exceeded 8000 I introduced a scale factor so they could be seen on the screen together and adjusted the Y axis so that each frequency appeared bottom to top in the order of analysis.

Screen Shot 2016-03-31 at 18.18.40

Quite nice, but there’s a lot of white space where the unused frequency range lies. Instead of removing this range from the visualisation (which, in retrospect, might have been a good idea) I decided to attempt to create ghosts of the circles fading out as they get further from the original position. This led me into colorsys and all sorts of bother, reminding me (eventually) not to mess with anything that returns a Tuple until I convert it back to a List first. Anyway, I removed that part of the code and put my arty effects on the back burner. You can see one example of the mess below. Ugh.

Screen Shot 2016-03-31 at 18.19.00

I decided to alter the colour of the background this time too. I think I’d like to use some audio analysis to decide on the colour range in a future version so that low audio frequencies create darker images and high frequencies create bright, bubblegum pop images.

Screen Shot 2016-03-31 at 18.06.42

The last thing I added to the program was the option to use pre-recorded audio WAV files instead of always recording 5 seconds of audio. This was very easy to add as I’d modularised the code as I went, so all that was needed was a few lines extra in the main program:

Screen Shot 2016-03-31 at 19.08.33

Trying out the program with a few WAV files from www.findsounds.com or playing a YouTube video in the background resulted in the following images:

chimpanzee.wav
chimpanzee.wav
uptown funk
uptown funk

Python files can be found at Github – https://github.com/familysimpson/PythonArt/. Feel free to fork the code, leave comments below or just enjoy the images it generates!

Computer Generated Art #thisismyclassroom #programming #steam

Computer Generated Art #thisismyclassroom #programming #steam

Screen Shot 2016-03-31 at 02.22.22

I wanted to create a task that allowed students to create a computer program in Python that would automatically create its own artwork but be customisable so that each student could experiment and personalise their own program to their tastes.

Screen Shot 2016-03-31 at 02.15.10

It’s a rough Python 3 program using the Turtle library and an array of Turtles but so far it has produced some really nice work. In the images shown below the program uses a user-defined function that draws a randomly sized square. I thought this would be easy for the students to understand and hack into something new!

Screen Shot 2016-03-31 at 02.15.24

Of course art can be created as a response to an external stimulus so a possible extension of this program would be to get input from the user (colours, mood, age) or calculate a range of colours from an input sensor or device (temperature, time, image).

Screen Shot 2016-03-31 at 02.15.38

The code is below! Any suggestions or improvements would be appreciated!

import turtle
import random
wn = turtle.Screen()
w = wn.window_width()
h = wn.window_height()

t1 = turtle.Turtle()
t2 = turtle.Turtle()
t3 = turtle.Turtle()
t4 = turtle.Turtle()
t5 = turtle.Turtle()
t6 = turtle.Turtle()

turtles = [t1, t2, t3, t4, t5, t6]

def square(item, size):
for x in range(4):
item.forward(size)
item.right(90)
item.forward(size)
item.left(random.randrange(-180, 180))

wn.tracer(False)
for iteration in range(3):
for item in turtles:
item.penup()
item.goto(random.randrange(-w,w),random.randrange(-h,h))
item.color(random.randrange(0,255)/255.,random.randrange(0,255)/255.,random.randrange(0,255)/255.)
item.pendown()
wn.tracer(False)
for move in range(2500):
for item in turtles:
item.speed(0)
square(item,random.randrange(5,25))
wn.tracer(True)

wn.exitonclick()

Screen Shot 2016-03-31 at 02.51.34

Screen Shot 2016-03-31 at 02.54.57

Using CodeBug tethered via USB on a MacBook

It has been a few weeks since our CodeBugs arrived here in Milan and after playing around with some of the sample programs and thinking about their features I have decided to use these with next session’s Year 10 students as an introduction to the iGCSE Computer Science course in September.

While they worked really well with the Raspberry Pi I struggled to get the CodeBugs working with IDLE on the MacBook. Installing packages via Terminal updated the Python 2.7 install that comes with the OS and – for me anyway – Homebrew complicated what should have been a very easy process. In Visual Studio if you wanted to use a module library you simply added it to the project and IDLE does not have this function.

I found PyCharm today – an IDE for Python that allows me to add the codebug_tether module (and any others I need) with the minimum of fuss. Now my CodeBug can be programmed while connected via USB to my MacBook! As an added bonus I learned more about Virtual Environments.

IMAG1237

To make it easier for my students to get going with their CodeBugs in September I created a 20-step guide linked here. It’s CC0 so please feel free to use and adapt as required. If you find any mistakes or it just doesn’t work for you in the same way please let me know.

Using @EdPuzzle for the first time #flipclass #flipchat

EdPuzzle is not a new site to me, however I’ve never had the time to sit down and investigate it properly. I got the opportunity today as the rain made an overdue visit to Milan.

My Year 10 Computer Science students are revisiting the Python language and I gauged their knowledge during class last week. As they all selected similar problems to solve I decided to share my solutions via video and take advantage of the embedded questioning offered by EdPuzzle.

I had intended to link to the finished EdPuzzle from a Google Form and then mark student submissions using Flubaroo however I was happy to see that EdPuzzle linked to Google Classroom and recorded student results and progress for me.

I’ve attached a quick video walkthrough of one of the tasks below, in case you want to see how it works. I think that next time I’ll make one video so that students do not have two tasks to complete but would appreciate any other feedback or suggestions!

Hour of Code Around the World (Event) #edchat #ukedchat #aussieED

code-944499_1280

After some discussion with a friend and former colleague (and some thinking over a few coffees) I was inspired to post a short tweet yesterday:

Screen Shot 2015-11-07 at 10.02.02

My aim is to get a small number of schools involved in a Google Hangout on Friday 11th December, code together and learn a little about how Computer Science is taught in schools in different parts of the world.

Even if timezones prevent schools from taking part in the Google Hangout there is still a chance to take part.

Interested in finding out more? Send me a tweet @familysimpson.

Why teaching ICT cannot be abandoned

By Photos public domain.com [Public domain], via Wikimedia Commons
As Russel Tarr’s recent response to a high-profile attack on his methods of teaching the history of the Weimar Republic (1918-33) gathers deservedly increasing views across the Internet, other parts of Michael Gove’s “Mr. Men” speech align with my concerns about the move away from teaching of ICT in schools and its replacement with (the far more high-brow sounding) Computing Science.

“As long as there are people in education making excuses for failure, cursing future generations with a culture of low expectations, denying children access to the best that has been thought and written, because Nemo and the Mister Men are more relevant, the battle needs to be joined.” (Michael Gove, 2013)

Contrast with one of the recommendations from the Next Gen. report mentioned by Michael Gove:

“Recommendation 3: Use video games and visual effects at school to draw greater numbers of young
people into STEM and computer science.” (Next Gen., Ian Livingstone & Alex Hope, 2011)

The draw of the shiny and new! As scenarios go I would far rather create video games or animations related to Finding Nemo or the Mr. Men than Of Mice and Men and Henry V and I’m pretty sure my students would too, given the choice. Seriously though, creating video games and visual effects using industry-standard software applications requires advanced problem solving skills, application of mathematics and physics and understanding of how a computer system can turn instructions into actions on the screen. It also involves management skills, teamwork, design and creativity. My concern is that a large number of schools are using the headline “games design”, “app design” or “computer animation” to try and reverse declining numbers taking the subject, then use the same teaching methods as they did with package skills…

“What has been wrong with education and IT is that it has been very much focused on the clerical aspect of IT – Microsoft Word, Powerpoint – and that has gone into every remit of the curriculum. It is about giving students access and inspiration so when they go into the wider world of work they are part of the technological advances of the country.” (Depute Principal of St Matthew Academy, http://www.bbc.co.uk/news/education-16186705)

“It was a boring set of documents that encouraged boring teaching of boring tasks in a field which should be one of the most exciting in education. The ICT curriculum we inherited was a tedious run-through the use of applications which were becoming obsolete even as the curriculum was being written.” (Michael Gove again, 2013)

But look at this: Lucasfilm want Interns! A quick glance at the essential and desired skills required for a role in Singapore – riding high in a recent index of cognitive skills and educational attainment – the  show a need for:

Education, Experience and Skills:

  • Interest in film production, digital games and media arts preferred
  • Workplace professionalism
  • Multitasking skills – Working on multiple projects with strict deadlines
  • Ability to work well in a multi-cultural team environment with diverse personalities
  • Strong verbal and written communication skills
  • Computer skills: Microsoft Word, Excel, Outlook. FileMaker Pro experience a plus.

So an interest in digital media would be desired but most important are: social skills, time management, presentation skills and ICT skills to aid communication (wouldn’t that be classed as clerical skills?). The only other nod to multimedia computing on the page is a request to “link to your online/downloadable reel or portfolio (if you have these)”. Yes this is just one example but highlights the need for continued teaching of ICT. Perhaps just in a different way?

As a programmer I’m glad the focus has been shifted back to using computer systems to create software or link to hardware devices such as the Raspberry Pi or Arduino but without ICT skills linked to the essential processes involved in the world of work and Higher Education, you risk creating skilled coders who are unable to apply for and retain the jobs waiting for them to fill.

“For children who have become digital natives and who speak fluent technology as an additional language, the ICT curriculum was clearly inadequate.” (more from Michael Gove, 2013)

Perhaps rigour in teaching ICT skills and ensuring that the skills they learn are relevant to the rest of the curriculum at the right time would make them more useful. I’m keen on not having ICT on the timetable as it identifies it as a unique entity – unrelated to other subjects the student encounters at school. Tracking progress at primary school and allowing individual students to follow challenging pathways which further develop their skills is tricky to plan and implement, but I think also extremely important.

Here’s why: Children are, in the main, not digital natives. They might wear the badge with honour but, without developing their understanding of what a “digital native” actually is, you may find they are wearing that badge upside down. Students may be confident enough to explore and experiment when faced with a new software application but find it very difficult to recall practical skills when the Computing department see them for around an hour each week (if you’re lucky!).

The solution mooted in Scotland a few years ago was to teach ICT in every subject and leave the programming and multimedia-specific elements to Computing Science teachers. Increased exposure to tasks which relied on students applying their ICT skills to solve problems, create reports or prepare presentations would reinforce practical skills and re-engage disaffected learners. Great idea, poorly planned and implemented due to a stunning lack of staff CPD, limited resources for using ICT in all subjects, corporate filtering and application deployment systems and push-back by subject teachers who felt they had enough to cover already without also including ICT in their remit. It is understandable: staff need to trust that the technology will work consistently enough to be able to teach their subject content. If it is unreliable and the root cause is not remedied, it will be treated as a strategy that does not provide benefit to the student – and abandoned.

The current pedagogy of how ICT lessons are delivered, assessed and reinforced must change to suit the needs of the individual learner.

Programming on an iPad #compSci #RGCdevicetrial

At the start of the #RGCdevicetrial I was very cynical about the effectiveness of iPads in education. I did not think they were suitable for use in secondary school classrooms. I saw them as content consumption devices, tailored for personal use only, and an expensive gimmick destined to gather dust in a department store cupboard (much like the iPod touch devices bought en-masse a few years ago).

I’m happy to state that I was wrong. For me, the iPad is a very strong contender for not only becoming the device of choice at our school but for eventually replacing desktop PCs in the Computing classroom too.

Like many others I thought it wasn’t possible to program on the iPad. I’d heard about Scratch being removed from the App Store and, whilst working on a successful Internet Safety project at Inverurie Academy in 2011, had fought a battle of wits with XCode to create and install a series of simple apps on the aforementioned iPod touch devices. I didn’t want to rely on having a spare Macbook sitting around for pupils to code on, in a language that was fairly impenetrable, just to be able to use the iPad in a Computing Science classroom.

However, after speaking to Fraser Speirs at a SCIS event in Edinburgh a few weeks ago, I realised that it was possible. He told me about Pythonista, which allows you to create command-line or graphical programs straight on the iPad. Fraser also told me that he pays for processing time on Amazon servers and gets students to upload code from their iPads and execute it remotely. The extra benefit of this, he says, is that his pupils have access to the same programming environment regardless of their location. It allows them to continue coding at home on a task they may have started in school.

For early stage programmers one app that helps build coding foundations through sequential instructions is A.L.E.X. I downloaded it whilst setting up the iPad for the #RGCdevicetrial and accidentally syncronised it with the iPad Mini which was being used by the ICT specialist in our primary school. She loved the app so I gave it a go last week while learning more about how an iPad mirrors to a data projector using Apple TV. There were young pupils in the playground outside with their noses against the window as they watched the robot move through the levels.

This morning I spotted a retweet by Dawn Halybone and had to investigate further:

20130313-231307.jpg

Snap! is a web-based drag and drop programming language developed at Berkeley. Very similar to Scratch, you create programs by associating scripts with sprites on a stage. It runs through a browser so you have to be online to use it however it looks very stable on the iPad. Even though the most recent Scratch beta is also web-based, it does not work with the iPad due to the fact it needs Adobe Flash to play content. I wasn’t even able to access the code screen on the site so, for the moment anyway, Snap seems to be the only option.

Do you know of any other apps or websites that allow programming on the iPad? Please share!

Higher Computing, Programming and Edmodo Badges

40 days since the start of term and my Higher Computing class are now comfortable using Edmodo. We have explored notification options and most of my students seem very quick to check the site when replies and new posts appear. I was online this evening and noticed that a few of the students had logged on as well. (I wonder if it was to see if anything new had been posted or to recap previous posts and resources? I’d love Edmodo to introduce a feature that showed a student’s active time on the site). I realised that I could quickly provide them with a pre-lesson task as well as explain what is to be covered in the coming week and posted the following:

 

 

The new scheduling feature in Edmodo is excellent. I’ve lined up my resources to appear tomorrow morning just before class begins so I know any response to the above is a result of the student’s own work or Internet research. For example, this was posted soon after:

 

 

 

This isn’t quite right but gave me the opportunity to intervene before the lesson tomorrow with a quick reply:

 

 

 

 

 

I would have loved more responses this evening but I have to admit it was a little late when I posted the message. I intend to try this again, but set up the message to appear on Friday afternoon to maximise the opportunity for all students to contribute.

And win those badges of course.