Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> >>> ================================ RESTART ================================ >>> ================================ RESTART ================================ >>> >>> print_5_things(1,2,3,4,'gorilla') 1 2 3 4 gorilla >>> ================================ RESTART ================================ >>> >>> print_5_things(1,2,3,4,'gorilla') 1 2 3 4 gorilla >>> def print_3_times(word): print(word*3) >>> print_3_times('book') bookbookbook >>> def print_3_times(word): print(word+word+word) >>> print_3_times('book') bookbookbook >>> def print_3_times(word): print(word, word, word) >>> print_3_times('book') book book book >>> def print_3_times(word): print(word+' '+word+' '+word) >>> print_3_times('book') book book book >>> def print_3_times_newlines(word): print(word,'\n',word,'\n',word) >>> print_3_times_newlines('book') book book book >>> def print_3_times_newlines(word): print(word'\n'word'\n'word) SyntaxError: invalid syntax >>> def print_3_times_newlines(word): print(word+'\n'+word+'\n'+word) >>> print_3_times_newlines('book') book book book >>> def print_3_times_newlines2(word): print(word) print(word) print(word) >>> print_3_times_newlines2('book') book book book >>> print(5) 5 >>> def print_3_times_newlines3(word): print(str(word)+'\n'+str(word)+'\n'+str(word)) >>> print_3_times_newlines(5) Traceback (most recent call last): File "", line 1, in print_3_times_newlines(5) File "", line 2, in print_3_times_newlines print(word+'\n'+word+'\n'+word) TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> print_3_times_newlines3(5) 5 5 5 >>> 'abc' 'abc' >>> 5 5 >>> '5' '5' >>> ' SyntaxError: EOL while scanning string literal >>> '\n' '\n' >>> ================================ RESTART ================================ >>> >>> farenheit_to_celcius(74) >>> ================================ RESTART ================================ >>> >>> farenheit_to_celcius(74) 23.3333333333 >>> farenheit_to_celcius(74)+2 23.3333333333 Traceback (most recent call last): File "", line 1, in farenheit_to_celcius(74)+2 TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' >>> ================================ RESTART ================================ >>> >>> farenheit_to_celcius(74)+2 23.3333333333 25.333333333333336 >>> farenheit Traceback (most recent call last): File "", line 1, in farenheit NameError: name 'farenheit' is not defined >>> output = farenheit_to_celcius(74)+2 23.3333333333 >>> output 25.333333333333336 >>> output 25.333333333333336 >>> 31+28+31+30+25 145 >>> 50 - 31 19 >>> 5 5 >>> five = 5 >>> five 5 >>> five = 75 >>> five 75 >>> import keyword >>> keyword.kwlist ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] >>> True = 5 SyntaxError: assignment to keyword >>> def True (abc): SyntaxError: invalid syntax >>> def true (abc): return(True) >>> true(5) True >>> import math >>> help(math) Help on module math: NAME math FILE /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynload/math.so MODULE DOCS http://docs.python.org/library/math 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 an int. 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) Convert 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 an int. 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(...) fsum(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 Check if float x is infinite (positive or negative). isnan(...) isnan(x) -> bool Check if float x is not a number (NaN). ldexp(...) ldexp(x, i) Return x * (2**i). log(...) log(x[, base]) Return the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. log10(...) log10(x) Return 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) Convert 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.718281828459045 pi = 3.141592653589793 >>> import = 5 SyntaxError: invalid syntax >>> 5ways_to_do_it = 5 SyntaxError: invalid syntax >>> ================================ RESTART ================================ >>> >>> get_distance_traveled(5,5) Calculating the distance traveled given speed of 5 and time of 5 25 >>> ================================ RESTART ================================ >>> >>> get_distance_traveled(5,5) Calculating the distance traveled given speed of 5 and time of 5 The answer is 25 25 >>> get_distance_traveled(5,5) + 5 Calculating the distance traveled given speed of 5 and time of 5 The answer is 25 30 >>> print(get_distance_traveled(5,5), 'is the answer') Calculating the distance traveled given speed of 5 and time of 5 The answer is 25 25 is the answer >>> def gds (s, t): return (s* t) >>> gds(5,5) 25 >>> def why_D_Cheney_should_be_in_jail(): print('He used a firearm while intoxicated, a felony') >>> output = why_D_Cheney_should_be_in_jail() He used a firearm while intoxicated, a felony >>> output >>> def print_3_times(word): print(word+' '+word+' '+word) >>> print_3_times('duck') duck duck duck >>> output = print_3_times('duck') duck duck duck >>> output >>> def the_secret_of_life() return(42) SyntaxError: invalid syntax >>> def the_secret_of_life(): return(42) >>> output = the_secret_of_life() >>> output 42 >>> the_secret_of_life() 42 >>> type(5) >>> type('hello') >>> type(output) >>> import math >>> math.pi 3.141592653589793 >>> math.pi = 3 >>> math.pi 3 >>> import math >>> math.pi 3 >>> math.pi = 3.141592653589793 >>> math.pi 3.141592653589793 >>> this_year Traceback (most recent call last): File "", line 1, in this_year NameError: name 'this_year' is not defined >>> this_year = 2011 >>> this_year 2011 >>> this_year = this_year * 3 >>> this_year 6033 >>> this_year 6033 >>> def print_this_year(): print(this_year) >>> print_this_year() 6033 >>> def mess_with_this_year (): this_year = 'the year one' print(this_year) >>> mess_with_this_year() the year one >>> this_year 6033 >>> def do_something(): something = 'cheese' print(something) >>> do_something() cheese >>> something Traceback (most recent call last): File "", line 1, in something NameError: name 'something' is not defined >>> print_this_year() 6033 >>> def globally_mess_with_this_year (): global this_year this_year = 'the year one' print(this_year) >>> globally_mess_with_this_year() the year one >>> this_year 'the year one' >>> def praise (input_string): return(input_string+' is nice') >>> def disagree (input_string): return('I disagree with the statement: ' + input_string) >>> praise('coffee') 'coffee is nice' >>> disagree('Y is a crooked letter') 'I disagree with the statement: Y is a crooked letter' >>> disagree(praise('coffee')) 'I disagree with the statement: coffee is nice' >>>