Detailed message: [Errno 2] No such file or directory: 'thisfiledoesnotexist.txt'

Traceback (most recent call last):


File "<ipython-input-15-fceaed5286c6>", line 1, in <module>

runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/lecture05-exceptions.py", line 20, in <module>

complicated_function(10)


File "/Users/progprim/Desktop/lecture05-exceptions.py", line 11, in complicated_function

raise NotImplementedError(msg)


NotImplementedError: Complicated_function(x) called with x=10



In [16]: runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')

Couldn't find the file.


In [17]: runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')

Couldn't find the file.


In [18]: runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')

Couldn't find the file.


In [19]: runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')

step 1

Couldn't find the file.


In [20]: runfile('/Users/progprim/Desktop/lecture05-file-reading.py', wdir='/Users/progprim/Desktop')

7

Traceback (most recent call last):


File "<ipython-input-20-d4d0a9a9276e>", line 1, in <module>

runfile('/Users/progprim/Desktop/lecture05-file-reading.py', wdir='/Users/progprim/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/lecture05-file-reading.py", line 26, in <module>

print_line_sum_of_file('linedata.txt')


File "/Users/progprim/Desktop/lecture05-file-reading.py", line 15, in print_line_sum_of_file

value = int(item)


ValueError: invalid literal for int() with base 10: 'cat'



In [21]: runfile('/Users/progprim/Desktop/lecture05-exceptions.py', wdir='/Users/progprim/Desktop')

step 1

Couldn't find the file.

Still going ....


In [22]: runfile('/Users/progprim/Desktop/lecture05-file-reading.py', wdir='/Users/progprim/Desktop')

7

-10


In [23]: print(42)

42


In [24]: str(42)

Out[24]: '42'


In [25]: 42.__str__()

File "<ipython-input-25-39da35cda040>", line 1

42.__str__()

^

SyntaxError: invalid syntax



In [26]: (42).__str__()

Out[26]: '42'


In [27]: a = 42


In [28]: a.__str__()

Out[28]: '42'


In [29]: "%f" % 3.14

Out[29]: '3.140000'


In [30]: "my number is %f" % 3.14

Out[30]: 'my number is 3.140000'


In [31]: "my number is %d" % 3.14

Out[31]: 'my number is 3'


In [32]: "my number is %i" % 3.14

Out[32]: 'my number is 3'


In [33]: "my number is %e" % 3.14

Out[33]: 'my number is 3.140000e+00'


In [34]: "my number is %g" % 3.14

Out[34]: 'my number is 3.14'


In [35]: "my number is %g" % 3.14e10

Out[35]: 'my number is 3.14e+10'


In [36]: "my number is %f" % 3.14

Out[36]: 'my number is 3.140000'


In [37]: "my number is %.3f" % 3.14

Out[37]: 'my number is 3.140'


In [38]: "my number is %10.3f" % 3.14

Out[38]: 'my number is 3.140'


In [39]: print("my number is %10.3f" % 3.14)

my number is 3.140


In [40]: print("numbers are %10.3f and %i" % (3.14, 42))

numbers are 3.140 and 42


In [41]: "numbers are %10.3f and %i" % (3.14, 42)

Out[41]: 'numbers are 3.140 and 42'


In [42]: "%s" % "cat"

Out[42]: 'cat'


In [43]: "%10s" % "cat"

Out[43]: ' cat'


In [44]: "%-10s" % "cat"

Out[44]: 'cat '


In [45]: "My object is %s" % 42

Out[45]: 'My object is 42'


In [46]: "My object is %s" % [1, 2, 3]

Out[46]: 'My object is [1, 2, 3]'


In [47]: 'peter' + 5

Traceback (most recent call last):


File "<ipython-input-47-3f0e1cd068ef>", line 1, in <module>

'peter' + 5


TypeError: Can't convert 'int' object to str implicitly



In [48]: 'peter' + str(5)

Out[48]: 'peter5'


In [49]: print('peter', 5)

peter 5


In [50]: print('peter' + 5)

Traceback (most recent call last):


File "<ipython-input-50-b4eca239dbd4>", line 1, in <module>

print('peter' + 5)


TypeError: Can't convert 'int' object to str implicitly



In [51]: import date

Traceback (most recent call last):


File "<ipython-input-51-c9fb87721c28>", line 1, in <module>

import date


ImportError: No module named 'date'



In [52]: import datetime


In [53]: t = datetime.datetime.now()


In [54]: str(t)

Out[54]: '2016-09-21 15:06:34.835793'


In [55]: repr(t)

Out[55]: 'datetime.datetime(2016, 9, 21, 15, 6, 34, 835793)'


In [56]: t2 = datetime.datetime(2016, 9, 21, 15, 6, 34, 835793)


In [57]: t == t2

Out[57]: True


In [58]: str(t)

Out[58]: '2016-09-21 15:06:34.835793'


In [59]: repr(t)

Out[59]: 'datetime.datetime(2016, 9, 21, 15, 6, 34, 835793)'


In [60]: eval(repr(t))

Out[60]: datetime.datetime(2016, 9, 21, 15, 6, 34, 835793)


In [61]: 0.5

Out[61]: 0.5


In [62]: 2

Out[62]: 2


In [63]: 2.

Out[63]: 2.0


In [64]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')


In [65]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0 0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [66]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [67]: list(range(0, 10, 0.5))

Traceback (most recent call last):


File "<ipython-input-67-3f3b5bce2c62>", line 1, in <module>

list(range(0, 10, 0.5))


TypeError: 'float' object cannot be interpreted as an integer



In [68]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [69]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [70]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [71]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [72]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 7.888609052210118e-31

1.0 1.0

1.5 4.065611775352152e+17

2.0 1.2676506002282294e+30

2.5 6.223015277861142e+39


In [73]: import math


In [74]: math.sin?

Docstring:

sin(x)


Return the sine of x (measured in radians).

Type: builtin_function_or_method


In [75]: math.sin

Out[75]: <function math.sin>


In [76]: math.sin(0)

Out[76]: 0.0


In [77]: math.sin

Out[77]: <function math.sin>


In [78]: g = math.sin


In [79]: g(0)

Out[79]: 0.0


In [80]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.479425538604203

1.0 0.8414709848078965

1.5 0.9974949866040544

2.0 0.9092974268256817

2.5 0.5984721441039564


In [81]: math.pow?

Docstring:

pow(x, y)


Return x**y (x to the power of y).

Type: builtin_function_or_method


In [82]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [83]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [84]: %reset


Once deleted, variables cannot be recovered. Proceed (y/[n])? y


In [85]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

Traceback (most recent call last):


File "<ipython-input-85-e27bebb638a3>", line 1, in <module>

runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/Desktop/printtable.py", line 48, in <module>

print_table(fx3)


NameError: name 'print_table' is not defined



In [86]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [87]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [88]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

Traceback (most recent call last):


File "<ipython-input-88-e27bebb638a3>", line 1, in <module>

runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/Desktop/printtable.py", line 49, in <module>

print_f_table(math.sin)


NameError: name 'math' is not defined



In [89]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 0.0

0.5 0.479425538604203

1.0 0.8414709848078965

1.5 0.9974949866040544

2.0 0.9092974268256817

2.5 0.5984721441039564


In [90]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

0.0 1.0

0.5 1.6487212707001282

1.0 2.718281828459045

1.5 4.4816890703380645

2.0 7.38905609893065

2.5 12.182493960703473


In [91]: math.sin

Out[91]: <function math.sin>


In [92]: dir(math.sin)

Out[92]:

['__call__',

'__class__',

'__delattr__',

'__dir__',

'__doc__',

'__eq__',

'__format__',

'__ge__',

'__getattribute__',

'__gt__',

'__hash__',

'__init__',

'__le__',

'__lt__',

'__module__',

'__name__',

'__ne__',

'__new__',

'__qualname__',

'__reduce__',

'__reduce_ex__',

'__repr__',

'__self__',

'__setattr__',

'__sizeof__',

'__str__',

'__subclasshook__',

'__text_signature__']


In [93]: math.sin.__name__

Out[93]: 'sin'


In [94]: fx2.__name__

Out[94]: 'fx2'


In [95]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

exp(0.0) = 1.0

exp(0.5) = 1.6487212707001282

exp(1.0) = 2.718281828459045

exp(1.5) = 4.4816890703380645

exp(2.0) = 7.38905609893065

exp(2.5) = 12.182493960703473


In [96]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

exp(0.0) = 1.0

exp(0.5) = 1.6487212707001282

exp(1.0) = 2.718281828459045

exp(1.5) = 4.4816890703380645

exp(2.0) = 7.38905609893065

exp(2.5) = 12.182493960703473

cos(0.0) = 1.0

cos(0.5) = 0.8775825618903728

cos(1.0) = 0.5403023058681398

cos(1.5) = 0.0707372016677029

cos(2.0) = -0.4161468365471424

cos(2.5) = -0.8011436155469337


In [97]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

exp(0.0) = 1.0

exp(0.5) = 1.6487212707001282

exp(1.0) = 2.718281828459045

exp(1.5) = 4.4816890703380645

exp(2.0) = 7.38905609893065

exp(2.5) = 12.182493960703473

Traceback (most recent call last):


File "<ipython-input-97-e27bebb638a3>", line 1, in <module>

runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/Desktop/printtable.py", line 52, in <module>

print_f_table(math.fx2)


AttributeError: module 'math' has no attribute 'fx2'



In [98]: runfile('/Users/progprim/Desktop/Desktop/printtable.py', wdir='/Users/progprim/Desktop/Desktop')

exp(0.0) = 1.0

exp(0.5) = 1.6487212707001282

exp(1.0) = 2.718281828459045

exp(1.5) = 4.4816890703380645

exp(2.0) = 7.38905609893065

exp(2.5) = 12.182493960703473

fx2(0.0) = 0.0

fx2(0.5) = 0.25

fx2(1.0) = 1.0

fx2(1.5) = 2.25

fx2(2.0) = 4.0

fx2(2.5) = 6.25


In [99]: