Pi Day | Python Program

by mrw122015 in Circuits > Computers

1985 Views, 4 Favorites, 0 Comments

Pi Day | Python Program

Evans-Pi-1.png

As you know already, pi is an endless number often used in math. It is celebrated on 3/14 (March 14th) because the standard use pi is 3.14

Please Note: I am doing this from a Mac, but it also works with extra software for windows. It also works in the Python Shell on the Raspberry Pi.

Step 1: Download and Install Textwrangler

Screen Shot 2016-03-28 at 10.25.22 AM.png

Download and install TextWrangler. To do this, go to http://www.barebones.com/products/textwrangler/ and select your computer version. Then download. I recommend that you do it from this website because it is the official one and it prevents the likelihood of virus and malware infections.

Once it is done downloading, open it.

Step 2: Create New Python Program

Screen Shot 2016-03-28 at 9.58.56 AM.png

Whether you are into computer programming (for this-python), or not, you just need to copy and paste the following code into a new document.

To Open a New Document: Go to File>New>Text Document

import time

today = raw_input("What is today??") if today == "pi day": print "Yea!!!" time.sleep(2) print "3.14159265358979323846"

This document will not be reading as if it is python till you tell it to. So, save your document. But, before you click save, change the extension (.txt) to .py

This will make it a python program that you can run.

Step 3: Run!

Screen Shot 2016-03-28 at 10.00.55 AM.png

Run your program by going to #!>Run in Terminal at the top of the screen. It may take a minute, but it will run your program in Terminal.

First, it will say: What is today?
Respond by typing:

 pi day

followed by the return key.

It will then say: Yea!!

Then, 3.14159265358979323846

After that, the program is done

If there is something specific you would like to add, but you do not program, let me know and I can try to elaborate on if for you and send you the code.

If you do program with python and you can make a really cool update to this code, let me know down below and I will definitly respond.

Any Questions?

Ask them below and I will respond.

Have a nice day!!