Wednesday, September 24, 2008

Chapter 2

Chapter 2 involves using numbers. The great thing about Python that I have noticed is that, if you don't know what type of number it is, then it will report back to you what type it is. I tested this out by trying out some types:
type(1)

type(99999999999)

type(4.0)

I wanted to create an imaginary number and it ended up being real simple. All you do is type the equation you would see on a test:

12j +1
(1+12j)

If you want to print out the format specifiers in Python, you can put % in front of it.

print "Lets print out the format specifier %%D"
'Lets print out the format specifier %D'

A cool feature I noticed with Python is that when you do math and get an answer like 300.666666667, when you print this answer it will come out precise like 300.67.
Python is neat along the lines of, if you have a math problem to do, you can type it in exactly how it looks and it will process the answer for you. 

The exercises at the end of the book are helpful with applying all the great features of numbers in Python.


Tuesday, September 23, 2008

Chapter 1

Its official, we are under way with our learning of Python. Chapter 1 is to introduce you to this new language. This will be prevalent throughout the following 2 chapters. If you are a beginning programmer, like me, at the end of this chapter we will have learned some simple guiding principles for programming. A key concept that Python wants the programmer to do is to think in blocks. This blocking technique allows you to think about larger projects in little pieces. This allows the programmer to make it understandable in many parts so you can extend the program farther if need be.  So for this first chapter, I just wanted to experiment with different types of strings.  The first thing I entered in was to use quotes: 

"Let see how python works" . This came back with the response 
'Let see how python works'.  

If I want to split the sentence up all I need to use is \n.  \n stands for new line. The only way for it to read it as a special character, you must have it translated to print.  

"Let see how \n  python works" won't make a new line.
a) print "Let see how \n python works"

'Let see how 
python works'

(The exercises clarify how \n works)

If you want to combine strings, it is just like Java. All you need is a + in between what you are writing.  
 

Wednesday, September 10, 2008

How To Get Python

In order to start things off, we need to sit down and download the Python program. Listed below is a tutorial of where and how to achieve this program.

This tutorial is for Windows Users:

1) Open the link below in a new window to the python website.
http://www.python.org/

2) On the left hand side, you will see a tab that is called "Windows Installer"

3) Once you click that, a file download window will pop up. Click Save and save it to a location where you will be able to find it.

4) The Python download tutorial should come up. Below is a video to go abouts doing this installation process. Start the video at 1 min 2 sec.

Video Tutorial of Running Python and Quick Beginner Tutorial

For Mac Users:

If you have recently purchased a Mac in the last 2 years, you already have it. The thing is, how do you execute the program.

1) Go into the Mac's Finder and type in Terminal.

2) Click on the program Terminal and type in Python.

3) Once typing in Python, press Enter and you have just opened Python.

*Note: Look at what it says, if it says "Python 2.5.2" then you are good. Some may say "Python 2.5.1" which is fine but it is not the most up to date version.

(For those Mac users who purchased their computer longer than two years follow these instructions or have an older version.)

1) Click on the link below to get to the official Python webpage.
http://www.python.org/

2) Look on the left side of your screen and click on the "Download" tab. This will bring you to another page.

3) Again, look on the left hand side under "Download"

4) Where it says "Macintosh," click on it.

If you cannot find Macintosh, this is a link to the website : Python for Mac

5) Find out what your operating software is for your Mac to choose which install package is good for you. This website gives you the links of which to install and will makes things much easier for you.

Monday, September 1, 2008

One of my favorite web comics is XKCD and they have a few strips that talk about Python. Links are below:

Comic 1

Comic 2

Comic 3


~Andrew Hayes