This program calculates a teenager’s pocket money on a monthly and yearly basis. It also calculates how much pocket money they will earn before they are 18.
You can see the code and output below, or you can access it on repl.it by clicking here.
Code
![](https://blogs.glowscotland.org.uk/glowblogs/public/insidem11/uploads/sites/10357/2023/04/21140217/image-7-1024x567.png)
![](https://blogs.glowscotland.org.uk/glowblogs/public/insidem11/uploads/sites/10357/2023/04/21140253/image-8-1024x314.png)
Output
![](https://blogs.glowscotland.org.uk/glowblogs/public/insidem11/uploads/sites/10357/2023/04/21140342/image-9.png)
New Constructs/Concepts
Calculations
This program shows how we can use mathematical symbols to perform calculations within our program. This is often combined with variable assignment in order to set a variable to the result of a calculation (which could involve the use of other variables).
The following mathematical symbols can be used.
Symbol | Mathematical Symbol |
---|---|
+ | Plus |
– | Minus |
/ | Divide |
* | Multiply |
^ | Exponent (to the power of) |
Construct | Line(s) | Python Syntax | Purpose |
---|---|---|---|
Calculations | 11, 14, 17 | +, -, /, *, ^ | To perform an addition, minus, division, multiplication, exponent |
Parson’s Problem
This program is designed to get the temperature in degrees celsius, then convert it to fahrenheit and display both temperatures.