Professional Documents
Culture Documents
[1]:
y=lambda x: x+8
In [2]:
y(6)
Out[2]: 14
In [3]:
g=lambda x: x*x*x*x
In [6]:
l1=[1,61,84,1218,1,91,324,47,12,61,2,61]
In [13]:
final_list=list(filter(lambda x:(x%2!=0),l1))
In [15]:
final_list
In [17]:
odd_list=list(filter(lambda x:(x%2!=0),l1))
In [18]:
odd_list
In [21]:
even_list=list(filter(lambda x:(x%2==0),l1))
In [22]:
even_list
In [26]:
multiple_of_3=list(filter(lambda x:(x%3==0),l1))
In [29]:
multiple_of_3
In [30]:
from functools import reduce
In [33]:
sum=reduce(lambda x,y: x+y,even_list)
In [34]:
sum
Out[34]: 1640
In [35]:
sumofl1=reduce(lambda x,y: x+y,l1)
In [36]:
sumofl1
Out[36]: 1963
In [37]:
sumofevenlist=reduce(lambda x,y: x+y,even_list)
In [38]:
sumofevenlist
Out[38]: 1640
In [40]:
sumofoddlist=reduce(lambda x,y: x+y,odd_list)
In [41]:
sumofoddlist
Out[41]: 323
In [42]:
newl1=[11,5,5,16,5316,46,13,6,1,46,9,16,87,6,1,6,65,4+9]
In [43]:
newl1
Out[43]: [11, 5, 5, 16, 5316, 46, 13, 6, 1, 46, 9, 16, 87, 6, 1, 6, 65, 13]
In [44]:
sumofnew=reduce(lambda x,y: x+y,newl1)
In [47]:
sumofnew
Out[47]: 5668
In [52]:
class Phone:
def make_call(self):
def Play_games(self):
print("Playing games")
In [55]:
p1=Phone()
In [60]:
p1.make_call()
In [63]:
p1.Play_games()
Playing games
In [109…
class Phone:
def set_color(self,color):
self.color=color
def set_cost(self,cost):
self.cost=cost
def show_color(self):
return self.color
def show_cost(self):
return self.cost
In [107…
p2=2
In [108…
p2.set_color("black")
---------------------------------------------------------------------------
<ipython-input-108-015d42e9f523> in <module>
----> 1 p2.set_color("black")
In [102…
p2.set_cost("8000")
In [103…
p2.show_cost()
Out[103… '8000'
In [104…
p2.show_color()
Out[104… 'black'
In [105…
p2.show_cost()
Out[105… '8000'
In [112…
Phone().show_cost
---------------------------------------------------------------------------
<ipython-input-112-adccad54795b> in <module>
----> 1 Phone.show_cost()
In [ ]: