Paul Sutton

Paul Sutton – personal blog

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,

Debian 12 release

Debian 12 (Bookworm) is scheduled for release on Saturday 10th June 2023.

We should be able to take a closer look at a future STEM group meeting.

Tags

#Computer,#OperatingSystem,#FreeSoftware,#Debian

American football – Torbay Trojans vs Cornwall Home

Next game is Sunday 4th June 2023. We are playing Cornwall Monarchs at home, kick off 14:00 at Foxhole field, Bellfield Road, Paignton.

Pitch marking will take place on Saturday 3rd June 2023 From 9:30.

Links

Fixtures

23rd April Wyverns vs Trojans 2pm Kick off 30th April Trojans vs Storm 2pm Kick off 21 May Dreadnoughts vs Trojans 2pm Kick off 28th May Trojans vs Dreadnoughts 2pm Kick off 4th June Trojans vs Monarchs 2pm Kick off 16th July Trojans vs Wyverns 30th July Storm vs Trojans 6th August Monarchs vs Trojans

Tags

#Trojans,#Football,#Training,#TorbayTrojans, #AlwaysTrojan,#Fixture,#CornwallMonarchs

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

Free Software Foundation workshop – 30th May 2023

BigCode: Open and responsible research on code-generating AI systems

BigCode: Open and responsible research on code-generating AI systems

Links

Tags

#FSF,#FreeSoftware,#Workshops

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

Still using Twitter ? Why ?

This is interesting, codes are there to keep people safe, voluntary or otherwise.

This was mentioned on the Fediverse

Should make an interesting discussion.

Fightback has started.

With the climate crises getting worse, floods, extreme weather, heat, storms all being linked to climate change and this in turn being linked to fossil fuels, the fight back has started.

Climate Earth have filed a case against the board of Shell as detailed below.

In February 2023, we filed a case against Shell’s Board of Directors for failing to move away from fossil fuels fast enough. This is the first ever case of its kind seeking to hold corporate directors personally liable.

In May 2023, the UK High Court dismissed the case, but has since granted us an oral hearing at which we will ask the Judge to reconsider.

You can read more here

We need action NOW, there is a lot of pessimism within the science community as to if we are actually going to reach our aims of reaching our target of avoiding a 1.5 degree global temperature rise See previous post here which links to an article in Nature.

Global temperatures are rising and this is the case even if you factor in events such as El-nino.

Hopefully the judge in will allow the court case to go ahead.

American football – Torbay Trojans vs Portsmouth Home

Next game is Sunday 28th May 2023. We are playing Portsmouth at home, kick off 14:00 at Foxhole field, Bellfield Road, Paignton.

Pitch marking will take place on Saturday 27th May.

Links

Fixtures

23rd April Wyverns vs Trojans 2pm Kick off 30th April Trojans vs Storm 2pm Kick off 21 May Dreadnoughts vs Trojans 2pm Kick off 28th May Trojans vs Dreadnoughts 2pm Kick off 4th June Trojans vs Monarchs 16th July Trojans vs Wyverns 30th July Storm vs Trojans 6th August Monarchs vs Trojans

Tags

#Trojans,#Football,#Training,#TorbayTrojans, #AlwaysTrojan,#Fixture,#PortsmouthDreadnoughts,#Dreadnoughts, #Portsmouth

Saturn Moon count Jumps

This was posted to Fedi on 19th May. New Scientist report on the moons around Saturn thanks to new research in to the rings. We are now up to 140, which surpasses the moons around Jupiter.

Saturn’s Youthful Rings and Newfound Moons Put It in Stargazing Spotlight

Links

Tags

#Astronomy,#Science.#Saturn,#Rings,#Moons,#MoonCount