Drake Curriculum links:
Conditional Selection (Year 5)
Variables (Year 6)
Functions (Subroutines) (KS3)
We programmed the basic logic of a banking app or ATM. First, we saved how much money is in the account in the 'savings' variable. Then, we asked the user how much money they want to take out using the input() function, saving whatever is given in a new variable. In order to respond with how much money is left, we took away the requested amount from the savings and saved it in a third variable. We then used Conditional Selection to test the third variable. If the money left is not less than zero, the program outputs a 'success' message along with the variable containing how much is left. Otherwise (else), it will feed back that there is not sufficient money in savings.
Here's Charley's code:
Astro Pi 2023
This year, our Astro Pi project has worked slightly differently. Instead of using Python to read humidity and temperature, a new sense function allows the Astro Pi to take in colours from the environment and save them in variables. In this way, the background of our images changes depending on what the Astro Pi camera can see.
Using variables we can make a program that seems to respond to what we have said. The program asks for answers using the input() function, saving the answers inside variables like Age or myName. We can then ask the program to print things like "Hello, how are you" + myName. In the example below, I answered 'Mr Fox' and that was stored in myName. When the above statement prints it will then read, "Hello, how are you Mr Fox".
Astro Pi 2022
The children used Python to write a program for the International Space Station. Small computers called Astro Pi received the code, reading the humidity and temperature of ISS and sending a message to the astronauts onboard. Their certificates show where above the earth the ISS was when it ran their code.
We have been using Python to make text-based adventure games. Using conditional selection (statements like if and else) we can control the flow of the program. We can say things like, "if the user selects option 1, then the computer will output a certain statement." Notice on line 7: decision1 = input(). The input() function asks whoever is using our program to type something; in this case, a number. The equals sign is used to store whatever is written by the user inside a variable called decision1. We can then use if/else statements to check what's saved in decision1 and then print out different responses.