First, download Python:

https://www.python.org/downloads/windows/

Unless you use some sort of integrated development environment, you will end up *typing* Windows commands into what is variously referred to as a “DOS window” or “Command prompt window”. Usually you can create such a window from your Start menu; under Windows 7 the menu selection is . You should be able to recognize when you have started such a window because you will see a Windows “command prompt”, which usually looks like this:

```
C:\>
```

The letter may be different, and there might be other things after it, so you might just as easily see something like:

```
D:\YourName\Projects\Python>
```

depending on how your computer has been set up and what else you have recently done with it. Once you have started such a window, you are well on the way to running Python programs.

You need to realize that your Python scripts have to be processed by another program called the Python *interpreter*. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program. So, how do you arrange for the interpreter to handle your Python?

First, you need to make sure that your command window recognises the word “python” as an instruction to start the interpreter. If you have opened a command window, you should try entering the command `python`

and hitting return.:

`C:\Users\YourName> python`

You have started the interpreter in “interactive mode”. That means you can enter Python statements or expressions interactively and have them executed or evaluated while you wait. This is one of Python’s strongest features. Check it by entering a few expressions of your choice and seeing the results:

```
>>> print ("Hello")
Hello
>>>print ("Hello" * 3)
'HelloHelloHello'
```

Common Commands:

– Clear screen:

*import os
os.system(‘cls’)*

a+b

Return the sum of a and b

a-b

Return the difference between a and b

a*b

Return the product of a and b

*a/b*

Return the result of dividing a and b

If a and b are integers, this result will be an integer, and represent the number of times

b fits into a

*1.0*a/b*

Return the value of a divided by b as a double (decimal)

*a**b*

Return the value of a raised to the b

*((a)**(b))**(1.0/c)*

Return the value of a raised to the b divided by c

*a += b*

Changes a to the value of a + b. This is equivalent to a = a + b

*list1[i]*

Return the ith item in a list named list1

l*en(s)*

Return the length (the number of items) of an object.

The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

Common mathematical functions in Python from http://docs.python.org/2/library/math.html.

*math.exp(x)*

Returns e**x.

*math.log(x[, base])*

With one argument, return the natural logarithm of x (to base e).

With two arguments, return the logarithm of x to the given base, calculated as

*log(x)/log(base).*

Analysis of Python Script Activity—Common Python Commands Sheet 2

*math.log10(x)*

Return the base-10 logarithm of x. This is usually more accurate than log(x, 10)

*math.pow(x, y)*

Return x raised to the power y. Exceptional cases follow Annex ‘F’ of the C99 standard as

far as possible. In particular, pow(1.0, x) and pow(x, 0.0) always return 1.0, even when x

is a zero or a NaN. If both x and y are finite, x is negative, and y is not an integer then

pow(x, y) is undefined, and raises ValueError.

Unlike the built-in ** operator, math.pow() converts both its arguments to type float.

Use ** or the built-in pow() function for computing exact integer powers.

*math.sqrt(x)*

Return the square root of x.

*math.acos(x)*

Return the arc cosine of x, in radians.

*math.asin(x)*

Return the arc sine of x, in radians.

*math.atan(x)*

Return the arc tangent of x, in radians.

*math.atan2(y, x)*

Return atan(y / x), in radians. The result is between -pi and pi. The vector in the plane

from the origin to point (x, y) makes this angle with the positive X axis. The point of

atan2() is that the signs of both inputs are known to it, so it can compute the correct

quadrant for the angle. For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1,

-1) is -3*pi/4.

*math.cos(x)*

Return the cosine of x radians.

*math.sin(x)*

Return the sine of x radians.

*math.tan(x)*

Return the tangent of x radians.

*math.pi*

The mathematical constant π = 3.141592…, to available precision.

*math.e*

The mathematical constant e = 2.718281…, to available precision.