Paul Sutton

Python

Code Club 1/7/2023

The next Paignton Library code club is on Saturday 1st July 2023 10 am to 12:00. We will carry on with with the Code Club projects, hour of code and perhaps hour of code.

Perhaps some more discussions around Technology, AI, Coding, etc.

I spent some time Friday afternoon setting up the room

code club 1

I have put some of the links from this below as a list.

Useful Links

If you also sign up to the Raspberry Pi foundation, you can track your own progress and collect badges. This is optional, as this presents more ways for data to be collected.

As before if you would like to save work, please sign up for a scratch or Trinket account so you can save project progress and carry on at home or at the next session.

Video

Tags

#CodeClub,#Projects,#Python,#Scratch,#Coding.#Programming,#Children, #Education

Code Club 17/6/2023 reminder and update

The next Paignton Library code club is on Saturday 17th June 2023 10 am to 12:00. We will carry on with with the Code Club projects. The write up from last session is here and the write up from Saturdays STEM group event is here.

I spent some time Friday afternoon setting up the room

code club 1 code club 2

I have put some of the links from this below as a list.

Useful Links

If you also sign up to the Raspberry Pi foundation, you can track your own progress and collect badges. This is optional, as this presents more ways for data to be collected.

As before if you would like to save work, please sign up for a scratch or Trinket account so you can save project progress and carry on at home or at the next session.

Video

Tags

#CodeClub,#Projects,#Python,#Scratch,#Coding.#Programming,#Children, #Education

Code Club 17/6/2023

The next Paignton Library code club is on Saturday 17th June 2023 10 am to 12:00. We will carry on with with the Code Club projects. The write up from last session is here and the write up from Saturdays STEM group event is here.

I have put some of the links from this below as a list.

Useful Links

If you also sign up to the Raspberry Pi foundation, you can track your own progress and collect badges. This is optional, as this presents more ways for data to be collected.

As before if you would like to save work, please sign up for a scratch or Trinket account so you can save project progress and carry on at home or at the next session.

Video

Tags

#CodeClub,#Projects,#Python,#Scratch,#Coding.#Programming,#Children, #Education

Raspberry Pi – Micropython book

I now have a copy of the Raspberry Pi, MicroPython book which is aimed at users of the Raspberry Pi Pico microcontroller board.

MicroPython book

I will bring this to the meeting today, along with some other resources. I also bought a Raspberry Pi Pico. I can experiment with this at home before Saturday.

pi pico

So hopefully, we can do some more hardware / software hacking with this.

#PaigntonLibrarySTEMGroup,#CodeClub,#Python,#Hardware, #Hacking

Code Club – Trinket and python Modules

Trinket allows you to use a number of different modules to add functionality to your programs.

Code Club have added a py5 module for their own projects. So this post will examine how to add one of the available libraries to your program.

Firstly a list of the modules that Trinket.io provides can be found here. along with some documentation for each.

So to add a module we need to use the import command.

Start with a blank new Python 3 project and enter the following

#!/usr/bin/env python3 #use python 3

Then the instruction to import the required module.

import numpy

Now test if you don't get errors proceed to add

from numpy import *

And test again.

Should give no errors, in which case you can now start to use module numpy

Other info

You can use modules such as Numpy and matplotlib in software such as Jupyter Notebook

Tags

#Python,#Trinket,#Modules,#HowTo,#CodeClub

Amazon's Ring used to spy on customers, FTC says in privacy settlement

Posted to the Fediverse yesterday. This is a stark warning about how technology can do what it wants, and how when we don't have access to the code that makes it work, we don't know what it is doing.

A good reason to support software freedom

You are better off with a RaspberryPi and a Camera Module along with a suitable programming language such as Python and hacking your own.

We can perhaps discuss at a future STEM Group.

Tags

#Amazon#Ring,#Privacy,#Spying.#Alternative,#FreeSoftware,#Python,#RaspberryPi,#CameraModule,#Hardware,#Hacking

New Python worksheets

I am now working on some new Python resources. I uploaded two of the resources mentioned in the previous post, and took some of the code from the TkInter resource (which is still available) and created a resource to look at testing if text from a user is what is being asked for.

As of 22/05/2023, I have :-

  • Python Arrays
  • Python String Length
  • Check User Input
  • Python3 Functions 2
  • Python3 Functions 1
  • Trinket Get Started
  • Python Nested Loops2
  • Python Nested Loops

These are designed to be used along side each other. As we are also using Trinket at Code Club.

My intention is to create more and use them as a Teaching Assistant or Tutor in a school or elsewhere. I am employed by an agency so if you want someone who can help teach computing in a primary school or have a group of children who want to move up then please get in touch. I can send my CV which will have my employer details on.

I can also help with Scratch, Micro:bit, electronics, Science etc

I will NOT be making these resources generally available.

These are already available

Tags

#CodeClub,#Python.#Programming,

Old python worksheets

A few years ago I created some worksheets to help teach nested loops. They are probably for Python2.x but can be adapted.

These are OLD and are therefore provided 'as is'. If you need help please send me a fediverse message on @[email protected]

Tags

#CodeClub,#Python.#Programming,

Code Club – Python functions 2

So to follow the previous post, we are going to look at passing 2 arguments to a function, adding them together, then displaying the result.

Firstly open a new Python Trinket

Firstly we are going to tell the interpreter to use python3.

#!/usr/bin/env python3 #use python 3

Now we create a function to take two arguments and display the sub of both

def add_numbers(x,z):
  #print(x)
  #print(z)
  add = (int(x) + int(z))
  print ('Total = ')
  print(add)

Get user input

x = input("First Number") # ask for first number
z = input("Second Number") # ask for second number

Convert to integers

int(x)
int(z)

Call function and pass values to function

add_numbers(x,z)

Tags

#CodeClub,#Python.#Programming,#Functions,#Arguments

Code Club – Simple Python 3 Functions

As we are learning Python at Code Club, I am going to make some related posts looking at the very basics of this. We are using Trinket.io for this

Firstly open a new Python Trinket

Firstly we are going to tell the interpreter to use python3.

#!/usr/bin/env python3 #use python 3

We are going to create a function called print_name() and then call it. The function will just print hello to the standard output.

def print_name():
  print ("hello")
  
print_name()  

So this in does the same as what

print ("hello")

To the next step is to run the function several times.

We could run

print_name()  
print_name() 
print_name() 

However it is probably better to put the print_name() in a loop, so it calls the function a specified number of times (in this case 4)

for x in range(0,4):
  print_name()

So this will now call the print_name() four times (or however many times is specified.

Assuming this works, we can now add some user interactivity

y = input("iterations")

As we are dealing with numbers (integers) than y will be a string we fix this in the line for x in range(0,int(y)): int(y) will convert string y in to integer y

Final program looks like this:-

def print_name(y):
  print ("hello")

y = input("iterations")
for x in range(0,int(y)):
  print_name(y)

Will ask for user input, store this in the variable y, as an integer. It run a loop which calls the function y times. Which in turn prints hello.

If you add the line

print(y)

After the

print("hello") 

Line, then the program should output a number count for each iteration. This can be a useful too for debugging loops. This will also make use of the fact we are passing the value of y to the function.

Links

Tags

#CodeClub,#Programming,#Education,#Python.#Functions