Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 2.6.5 >>> "Hello, world" 'Hello, world' >>> 45 45 >>> 45.5 45.5 >>> Hello, world Traceback (most recent call last): File "", line 1, in Hello, world NameError: name 'Hello' is not defined >>> 'GATATATATATA' 'GATATATATATA' >>> "Mark's DNA" "Mark's DNA" >>> """;alskdfjadfasdas alksdflaskdfjasdf asdfasdfa asdfsadfasdfa """ ';alskdfjadfasdas\nalksdflaskdfjasdf\nasdfasdfa asdfsadfasdfa\n' >>> 2+2 4 >>> 2-3 -1 >>> 2*3 6 >>> 4/3 1 >>> 4/3.0 1.3333333333333333 >>> float(4)/3 1.3333333333333333 >>> 2**3 8 >>> 2*3+2**3 14 >>> 2*(3+2) 10 >>> 2.1 - 3.2 -1.1000000000000001 >>> 3.0/2.8 1.0714285714285714 >>> "%.3f" % (2.1 - 3.2) '-1.100' >>> 2**3.1 8.574187700290345 >>> oxidative = 2.1 >>> oxidative 2.1000000000000001 >>> reductive = -1 >>> reductive -1 >>> oxidative - reductive 3.1000000000000001 >>> gene = "ATATATATATAT" >>> gene 'ATATATATATAT' >>> oxidative - gene Traceback (most recent call last): File "", line 1, in oxidative - gene TypeError: unsupported operand type(s) for -: 'float' and 'str' >>> difference = oxidative - gene Traceback (most recent call last): File "", line 1, in difference = oxidative - gene TypeError: unsupported operand type(s) for -: 'float' and 'str' >>> difference = oxidative - reductive >>> difference 3.1000000000000001 >>> population = 2 >>> population = population * 2 >>> population 4 >>> population *= 2 >>> population 8 >>> population *= 2 >>> population 16 >>> print population 16 >>> print population, oxidation 16 Traceback (most recent call last): File "", line 1, in print population, oxidation NameError: name 'oxidation' is not defined >>> print population, oxidative 16 2.1 >>> print population, oxidative, 5, reductive 16 2.1 5 -1 >>> yfg = "ATATATAT" >>> mfg = "ATATATAT" >>> ygf == mfg Traceback (most recent call last): File "", line 1, in ygf == mfg NameError: name 'ygf' is not defined >>> yfg == mfg True >>> hfg = "GTGTGTG" >>> hfg == mfg False >>> a = True >>> if(42 == 5): print "This shouldn't happen" else: print "It worked!" It worked! >>> if(42 == 5): print "This shouldn't happen" elif(2 == 2): print "hi" else: print "oops" hi >>> mylist = [1,2,3,4,5] >>> mylist [1, 2, 3, 4, 5] >>> mylist[0] 1 >>> mylist[-1] 5 >>> mylist[2] = "Hello" >>> mylist [1, 2, 'Hello', 4, 5] >>> mylist [1, 2, 'Hello', 4, 5] >>> a = mylist >>> a [1, 2, 'Hello', 4, 5] >>> a[3] = "World" >>> a [1, 2, 'Hello', 'World', 5] >>> mylist [1, 2, 'Hello', 'World', 5] >>> a = mylist[:] >>> a [1, 2, 'Hello', 'World', 5] >>> a[4] = 3 >>> a [1, 2, 'Hello', 'World', 3] >>> mylist [1, 2, 'Hello', 'World', 5] >>> for i in [1,2,3,4,5]: print i, i**2 1 1 2 4 3 9 4 16 5 25 >>> for i in [1,2,3,4,5]: print i, i**2 print "hi" 1 1 hi 2 4 hi 3 9 hi 4 16 hi 5 25 hi >>> population = 1 >>> while(population < 1e5): print population population *= 2 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 >>> >>> >>> x = [2,3,5,1,2] >>> index = 0 >>> for i in x: print index, i index += 1 0 2 1 3 2 5 3 1 4 2 >>> index = 0 >>> while(index < 5): print index, x[index] index += 1 0 2 1 3 2 5 3 1 4 2 >>> for index in [0,1,2,3,4]: print index, x[index] 0 2 1 3 2 5 3 1 4 2 >>> for (index, i) in enumerate(x): print index, i 0 2 1 3 2 5 3 1 4 2 >>> x [2, 3, 5, 1, 2] >>> x [2, 3, 5, 1, 2] >>> len(x) 5 >>> len("ATATATATATT") 11 >>> sum(x) 13 >>> range(5) [0, 1, 2, 3, 4] >>> range(2,5) [2, 3, 4] >>> range(5,1,-1) [5, 4, 3, 2] >>> help(range) Help on built-in function range in module __builtin__: range(...) range([start,] stop[, step]) -> list of integers Return a list containing an arithmetic progression of integers. range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0. When step is given, it specifies the increment (or decrement). For example, range(4) returns [0, 1, 2, 3]. The end point is omitted! These are exactly the valid indices for a list of 4 elements. >>> sum = 0 >>> sum(x) Traceback (most recent call last): File "", line 1, in sum(x) TypeError: 'int' object is not callable >>> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 2.6.5 >>> x = [1,2,3,4,6] >>> sum(x) 16 >>> import math >>> help(math) Help on built-in module math: NAME math FILE (built-in) DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(...) acos(x) Return the arc cosine (measured in radians) of x. acosh(...) acosh(x) Return the hyperbolic arc cosine (measured in radians) of x. asin(...) asin(x) Return the arc sine (measured in radians) of x. asinh(...) asinh(x) Return the hyperbolic arc sine (measured in radians) of x. atan(...) atan(x) Return the arc tangent (measured in radians) of x. atan2(...) atan2(y, x) Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered. atanh(...) atanh(x) Return the hyperbolic arc tangent (measured in radians) of x. ceil(...) ceil(x) Return the ceiling of x as a float. This is the smallest integral value >= x. copysign(...) copysign(x,y) Return x with the sign of y. cos(...) cos(x) Return the cosine of x (measured in radians). cosh(...) cosh(x) Return the hyperbolic cosine of x. degrees(...) degrees(x) -> converts angle x from radians to degrees exp(...) exp(x) Return e raised to the power of x. fabs(...) fabs(x) Return the absolute value of the float x. factorial(...) factorial(x) -> Integral Find x!. Raise a ValueError if x is negative or non-integral. floor(...) floor(x) Return the floor of x as a float. This is the largest integral value <= x. fmod(...) fmod(x,y) Return fmod(x, y), according to platform C. x % y may differ. frexp(...) frexp(x) Return the mantissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. fsum(...) sum(iterable) Return an accurate floating point sum of values in the iterable. Assumes IEEE-754 floating point arithmetic. hypot(...) hypot(x,y) Return the Euclidean distance, sqrt(x*x + y*y). isinf(...) isinf(x) -> bool Checks if float x is infinite (positive or negative) isnan(...) isnan(x) -> bool Checks if float x is not a number (NaN) ldexp(...) ldexp(x, i) -> x * (2**i) log(...) log(x[, base]) -> the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. log10(...) log10(x) -> the base 10 logarithm of x. log1p(...) log1p(x) Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero. modf(...) modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats. pow(...) pow(x,y) Return x**y (x to the power of y). radians(...) radians(x) -> converts angle x from degrees to radians sin(...) sin(x) Return the sine of x (measured in radians). sinh(...) sinh(x) Return the hyperbolic sine of x. sqrt(...) sqrt(x) Return the square root of x. tan(...) tan(x) Return the tangent of x (measured in radians). tanh(...) tanh(x) Return the hyperbolic tangent of x. trunc(...) trunc(x:Real) -> Integral Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. DATA e = 2.7182818284590451 pi = 3.1415926535897931 >>> math.sqrt(64) 8.0 >>> math.log(8) 2.0794415416798357 >>> math.log(8)/math.log(2) 3.0 >>> log2 = math.log(2) >>> math.log(8)/log2 3.0 >>> math.log(8,2) 3.0 >>> from math import log, sqrt >>> log(8,2) 3.0 >>> sqrt(9) 3.0 >>> sqrt(-1) Traceback (most recent call last): File "", line 1, in sqrt(-1) ValueError: math domain error >>> log = 5 >>> log(3) Traceback (most recent call last): File "", line 1, in log(3) TypeError: 'int' object is not callable >>> reload(math) >>> from math import log, sqrt >>> log(3) 1.0986122886681098 >>> x [1, 2, 3, 4, 6] >>> sum(x)/float(len(x)) 3.2000000000000002 >>> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 2.6.5 >>> import module1 >>> help(module1) Help on module module1: NAME module1 FILE /home/karmic/BMS270/module1.py FUNCTIONS myfunction(x) >>> myfunction([1,2,3,4,5]) Traceback (most recent call last): File "", line 1, in myfunction([1,2,3,4,5]) NameError: name 'myfunction' is not defined >>> module1.myfunction([1,2,3,4,5]) 15 >>> reload(module1) >>> module1.myfunction([1,2,3,4,5]) 20 >>> module1.myfunction([1,2,3,4,5]) 20 >>> reload(module1) >>> module1.myfunction([1,2,3,4,5]) I got here 20 >>>