from IPython.display import YouTubeVideo YouTubeVideo("KwDesuX1e_0")
#לא נכון
items = [-3.2, 4, True, 'a', 'A', ['as',4,1]]
print(len(items)-1)
5
5
a = []
print(type(a))
a = [] print(type(a))
my_list=[2,5,-2,12.3,7]
print (3*my_list[1])
my_list=[2,5,-2,12.3,7]
l1 = ['A', 'B', 7]
l2 = [1, 2, 3]
l1 + l2
l1 = ['a', 'b', 7] l2 = [1, 2, 3] l1 + l2
l1.append(l2)
#['a', 'b,', 7, [1, 2, 3]]
l1.append(l2)?
#[1, 2, 3]
mass = [1.23, 3.45, 6.7, 2.3, 11.5]
6.7 in mass
#True
l=[0]
l=[0] l*4
#[0, 0, 0, 0]
l1=[1,2,3]
l2=[0]
[0,0,0,1,2,3,0,0,0]
l1=[1,2,3] l2=[0] l2*3+l1+l2*3
l=[1,5,2,7]
[1,2,5,7,7,5,2,1,2,2,2,2,2]
l=[1,5,2,7] l.sort() l x=[1,5,2,7] x.reverse() x y=l+x y n=[1,5,2,7] n.remove(1) n.remove(5) y.remove(7) y+n*5
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-73-7c1773cd4af1> in <module>()
----> 1 l+l2
TypeError: can only concatenate list (not "NoneType") to list
range(start,stop,step)
r = range(-5,5,2) #+מחזיר רשימה. שני צעדים כל פעם. מתחיל מ 5- וממשיך עד < 5 i = 0 while i < len(r): print (r[i]) i = i + 1
list(r)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-114-9b31f56ba9a7> in <module>()
----> 1 list(r)
NameError: name 'r' is not defined
print(range(-2,3,1))
a=range(-2,3,1) list(a)
a=range(0,-4,-1) list(a)
a=range(7,20,3) list(a)
ex=[0,0.4,0.8] #הגדרתי בהתחלה רשימה x=0.8 while x<7 : x=x+0.5 ex.append(x) print(ex)
def array(start, stop, step): g=[] g.append(start) while start<stop-step: start=start+step g.append(start) return list (g) print (array(0.1,800.54,100.5))
x = [-2, 3, -5, 4]
y = [1.6, 7, 3.1, 9]
import matplotlib.pyplot as plt plt.plot(x ,y, 'ro')#איך קובעים את גודל הנקודה? plt.plot(x ,y, 'b.')# plt.xlabel('x', fontsize = 12) plt.ylabel('x', fontsize = 12) plt.grid(True) plt.title( 'x Vs y grph',fontsize = 18, color = 'blue')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-142-f12ff1196032> in <module>()
1 import matplotlib.pyplot as plt
----> 2 plt.plot(x ,y, 'ro')#איך קובעים את גודל הנקודה?
3 plt.plot(x ,y, 'b.')#
4 plt.xlabel('x', fontsize = 12)
5 plt.ylabel('x', fontsize = 12)
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2809 return gca().plot(
2810 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2811 is not None else {}), **kwargs)
2812
2813
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
1808 "the Matplotlib list!)" % (label_namer, func.__name__),
1809 RuntimeWarning, stacklevel=2)
-> 1810 return func(ax, *args, **kwargs)
1811
1812 inner.__doc__ = _add_data_doc(inner.__doc__,
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, *args, **kwargs)
1609 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
1610
-> 1611 for line in self._get_lines(*args, **kwargs):
1612 self.add_line(line)
1613 lines.append(line)
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
391 this += args[0],
392 args = args[1:]
--> 393 yield from self._plot_args(this, kwargs)
394
395
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
368 x, y = index_of(tup[-1])
369
--> 370 x, y = self._xy_from_xy(x, y)
371
372 if self.command == 'plot':
/ext/anaconda5/lib/python3.6/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
229 if x.shape[0] != y.shape[0]:
230 raise ValueError("x and y must have same first dimension, but "
--> 231 "have shapes {} and {}".format(x.shape, y.shape))
232 if x.ndim > 2 or y.ndim > 2:
233 raise ValueError("x and y can be no greater than 2-D, but have "
ValueError: x and y must have same first dimension, but have shapes (1,) and (7,)
a=[2,3,4,5] sum(a)
a=[2,3,4,5] zip(a)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-160-99c3e7c0d591> in <module>()
----> 1 x[1,1001]
TypeError: 'float' object is not subscriptable
from math import sqrt # sqrt צריכים להייבא מהספריה את הפקודה המחשבת שורש של מספר n=[] x=0 while x<1000: y= x**0.5 n.append(y) x=x+1 sum(n)
def avg(a,b,c): x=[a,b,c] n=sum (x) y=len (x) return n/y avg(80000,5,2)
x=[1,2,3,4] x.extend()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-4583bd2cf784> in <module>()
1 x=[1,2,3,4]
----> 2 x.extend()
TypeError: extend() takes exactly one argument (0 given)
avg(5,6,7)
s=[5,6,7] min(s)
s=[5,6,7] max(s)
import numpy as np import matplotlib.pyplot as plt a=np.arange(0,6.29,0.01) plt.plot(np.cos(a),np.sin(a))
import numpy as np import matplotlib.pyplot as plt a=np.arange(0,6.29,6.28/7) plt.plot(np.cos(a),np.sin(a))