Pythagoras Python Script

On Christmas Day, I received a Raspberry Pi Zero. I have a blog post coming soon on exactly how I have set it up. I randomly decided to make a Python script but I wanted one that would be practical and that would serve an actual purpose. After a couple of minutes, I had a brainwave.

As most of you probably don’t know, I am currently studying for my GCSEs. I am currently in year 11. In year 10, I learn’t about Pythagoras. In a nutshell, Pythagoras is a formula that you can use to find out the length of a missing side of a right handed triangle. Below is an example that I have created.

Pythagoras Worked Example. Copyright Jacob White 2016

I apologise for the poor quality but I’m sure you get the idea! I created this using notes on iOS.

You can re-arrange the equation so that you can find out the b and the a values. But, I decided to keep things simple so my program only finds out the c value. However, my program also rounds the answer to 2 decimal places.

If you understand my worked example, you will understand my program. Basically, my program firstly asks the user for the a and b values. It then completes each stage of Pythagoras and stores the answer to each step in a variable. To get the final answer, my program uses the ‘math’ Python library. It uses a function that is in the library to find the square root.

The answer is then printed out to the shell.

As I have learn’t, most exam questions ask you to round the answer to two decimal places. Luckily, the math library has a function that allows you to round numbers. The final thing that my program does is round the answer to two decimal places. The rounded answer is also printed to the shell.

Here is the program. I made this program using a text editor called nano.  But this program would easily run with IDLE 3.

I hope that you enjoyed this post and decide to replicate it yourself. Please feel free to experiment by editing this script.

 

Raspberry Pi Ultrasonic Sensor

Today, I went to Maplins to get some resistors to be able to use my ultrasonic sensor I won at a Raspberry Jam event. The hardware was reasonably easy. I only had a circuit diagram and a small breadboard to work with. I followed the Raspberry Pi Spy’s tutorial and used his code.

However, I haven’t quite got my Raspberry Pi to display the distance the sensor is from an object yet. It just displays ‘Ultrasonic Measurement’. I think it is due to my wiring. Any help would be gratefully appreciated.

New URL

I am currently moving this site to a new domain name. This is because my domain name contain a trademark owned by the ‘Raspberry Pi Foundation’. The site will then be called ‘Pi Guide’

I will be redirecting traffic to the new URL soon. I will be informing search engines about the change.

Also, I have an app on Google Play. There will be an update soon.

Raspberry Pi Quiz Android BETA Program

I have made an Android app called’ Raspberry Pi Quiz’. This is an app which tests your knowledge on the Raspberry Pi.

However, I need some people to come up with questions which I will use in the app. I am asking for some Raspberry Pi users to be BETA testers for the app.

To sign up click the Link below:

https://docs.google.com/forms/d/1HTfti7FHisxy48ZdqTEpjkhhH4YzneoKsQVE3zuZy6w/viewform