Kernel: Unknown Kernel
In [1]:
Out[1]:
Enter a number: seven
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-61ced4682ade> in <module>()
----> 1 x = float(raw_input('Enter a number: '))
ValueError: could not convert string to float: seven
In [1]:
Out[1]:
Enter a number: seven
seven cannot be converted to floating point number.
In [2]:
Out[2]:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-2-8d9c2d533693> in <module>()
1 list = [1,2,3,4]
----> 2 print(list[4])
IndexError: list index out of range
In [3]:
Out[3]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-03202d5db7db> in <module>()
1 from math import sqrt
----> 2 sqrt(-2)
ValueError: math domain error
In [4]:
Out[4]:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-4-bb76b55e818d> in <module>()
1 x = 0
2 y = 2
----> 3 a = y/x
ZeroDivisionError: integer division or modulo by zero
In [5]:
Out[5]:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-23441cc05d89> in <module>()
1 a = 2
----> 2 print(A)
NameError: name 'A' is not defined
In [6]:
Out[6]:
File "<ipython-input-6-d6ea3953da97>", line 1
a =* 2
^
SyntaxError: invalid syntax
In [9]:
Out[9]:
Please do not multiply strings by floats.
In [8]:
Out[8]:
abcabcabcabcabcabcabcabcabcabc
In [1]:
Out[1]:
Enter a number: seven
That's not a number.
Enter a number: aardvaark
That's not a number.
Enter a number: seven aardvaarks
That's not a number.
0
In [2]:
In [3]:
Out[3]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-1f37c601bc1e> in <module>()
2 return 3*x**2
3
----> 4 leftInt(f,0,4,3.5)
<ipython-input-2-b28beb750b2d> in leftInt(f, a, b, n)
5 b = float(b) #Will raise an exception if b cannot be converted to float.
6 if (type(n) != int) or (n <= 0):
----> 7 raise ValueError("number of rectangles must be a positive integer") #We don't want to convert n into an int...if the user passed in a non-int or negative, there clearly is a problem.
8 deltax = (b-a)/n
9 x = a
ValueError: number of rectangles must be a positive integer
In [4]:
Out[4]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-2b6f8aa6e3b6> in <module>()
2 return "You're a jerk!"
3
----> 4 leftInt(g,0,4,3)
<ipython-input-2-b28beb750b2d> in leftInt(f, a, b, n)
13 sum += f(x)
14 except TypeError:
---> 15 raise TypeError("integrand is not a valid function") #Sometimes we want to catch a particular exception and re-raise it with a more specific error message.
16 x += deltax
17 return deltax*sum
TypeError: integrand is not a valid function
In [1]:
Out[1]:
66.24
95.04
80.64
In [3]:
Out[3]:
78.5664
In [4]:
Out[4]:
[1 2 3 4 5 6]
In [5]:
Out[5]:
[ 1. 2. 3.1 4. 5. 6. ]
In [6]:
Out[6]:
[1, 2, 3, 4, 5, 6]
In [7]:
Out[7]:
[ 2. 4. 6.1 8. 10. 12.2]
In [8]:
Out[8]:
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
In [10]:
Out[10]:
[ 1. 1.21052632 1.42105263 1.63157895 1.84210526 2.05263158
2.26315789 2.47368421 2.68421053 2.89473684 3.10526316 3.31578947
3.52631579 3.73684211 3.94736842 4.15789474 4.36842105 4.57894737
4.78947368 5. ]
In [11]:
Out[11]:
[ 1. 1.77387374 2.8696603 4.34334451 6.25091121
8.64834524 11.59163143 15.13675463 19.33969966 24.25645138
29.94299461 36.45531419 43.84939496 52.18122175 61.50677941
71.88205278 83.36302668 96.00568596 109.86601545 125. ]
In [12]:
Out[12]:
[ 2.71828183 3.35525011 4.1414776 5.11193983 6.30980809
7.78836987 9.61339939 11.86608357 14.64663368 18.07874325
22.31509059 27.54413077 33.99847904 41.96525883 51.79887449
63.93677707 78.91892444 97.41180148 120.23806881 148.4131591 ]
In [13]:
Out[13]:
[-1. -0.78914051 -0.24548549 0.40169542 0.87947375 0.9863613
0.67728157 0.08257935 -0.54694816 -0.94581724 -0.94581724 -0.54694816
0.08257935 0.67728157 0.9863613 0.87947375 0.40169542 -0.24548549
-0.78914051 -1. ]
In [15]:
Out[15]:
209.473684211
10
In [16]:
Out[16]:
[-1 -1 1]
In [17]:
Out[17]:
[[ 1 2 3]
[ 3 -4 5]
[ 5 6 7]]
In [18]:
Out[18]:
[ 11.25664784 -0.89351035 -6.36313749]
[[ 0.32531663 0.85160988 0.09637145]
[ 0.35164354 -0.02060987 -0.92099553]
[ 0.87779036 -0.5237708 0.37746494]]
In [19]:
Out[19]:
63.999999999999979
In [20]:
Out[20]:
[[ 1 4 9]
[ 9 16 25]
[25 36 49]]
In [21]:
Out[21]:
[[22 12 34]
[16 52 24]
[58 28 94]]
In [ ]: