<jupyter_start><jupyter_text>Task - I   1.1Write a Python Program to implement your own myreduce() function which works exactly likePython's built-in function reduce()<jupyter_code>a = [123,5,23,345,23]
result = []
def myreduce(arg1,arg2,result):
    result = arg1[0]
    for i in range(len(a)):
        result+=arg2
    return result-arg2
myreduce(a,2,result)<jupyter_output><empty_output><jupyter_text>1.2Write a Python program to implement your own myfilter() function which works exactly likePython's built-in function filter()<jupyter_code>a = [1,-2,3,-4,5,-6]
res = []
def myfilter(arg1,res):
    for i in arg1:
        if i>0:
            res.append(i)
    return res
pos = myfilter(a,res)
pos<jupyter_output><empty_output><jupyter_text>2.Implement List comprehensions to produce the following lists.Write List comprehensions to produce the following Lists['A', 'C', 'A', 'D', 'G', 'I', ’L’, ‘ D’]['x', 'xx', 'xxx', 'xxxx', 'y', 'yy', 'yyy', 'yyyy', 'z', 'zz', 'zzz', 'zzzz']['x', 'y', 'z', 'xx', 'yy', 'zz', 'xx', 'yy', 'zz', 'xxxx', 'yyyy', 'zzzz'][[2], [3], [4], [3], [4], [5], [4], [5], [6]][[2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]][(1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)]  a).<jupyter_code>a = ['A', 'C', 'A', 'D', 'G', 'I', 'L', 'D']
[i*1 for i in a]<jupyter_output><empty_output><jupyter_text>b).<jupyter_code>a = ['x','y','z']
b = [1,2,3,4]
res = []
result = []
for i in a:
    res = [i*x for x in b]
    result+=res
print(result)<jupyter_output>['x', 'xx', 'xxx', 'xxxx', 'y', 'yy', 'yyy', 'yyyy', 'z', 'zz', 'zzz', 'zzzz']<jupyter_text>c).<jupyter_code>a = ['x','y','z']
b = [1,2,2,4]
res = []
result = []
for i in b:
    res = [i*j for j in a]
    result+=res
print(result)<jupyter_output>['x', 'y', 'z', 'xx', 'yy', 'zz', 'xx', 'yy', 'zz', 'xxxx', 'yyyy', 'zzzz']<jupyter_text>d).<jupyter_code>a = [2,3,4]
res = []
result = []
for i in range(3):
    res = [[i+j] for j in a]
    result+=res
print(result)<jupyter_output>[[2], [3], [4], [3], [4], [5], [4], [5], [6]]<jupyter_text>e).<jupyter_code>a = [2,3,4,5]
res = []
result = []
for i in range(4):
    res = [i+j for j in a]
    result.append(res)
print(result)<jupyter_output>[[2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]<jupyter_text>f).<jupyter_code>a = [1,2,3]
res = []
result = []
for i in range(1,4):
    res = [(j,i) for j in a]
    result+=res
result<jupyter_output><empty_output><jupyter_text>3.Implement a function longestWord() that takes a list of words and returns the longest one.<jupyter_code>def longestWord(arg1):
    maxt = 0
    for i in arg1:
        if maxt<len(i):
            maxt = len(i)
    return maxt
a = []
n = int(input("Enter n:"))
for i in range(n):
    temp = input()
    a.append(temp)
a
ans = longestWord(a)
ans
for i in a:
    if len(i)==12:
        print(i)<jupyter_output>data science<jupyter_text>Task - II   1.1Write a Python Program(with class concepts) to find the area of the triangle using the belowformula.area = (s*(s-a)*(s-b)*(s-c)) ** 0.5Function to take the length of the sides of triangle from user should be defined in the parentclass and function to calculate the area should be defined in subclass.<jupyter_code>class Tri:
    def __init__(self,a,b,c):
        self.a = a
        self.b = b
        self.c = c

class Area(Tri):
    def __init__(self,s,are,*args,**kwargs):
        super(Area,self).__init__(*args,**kwargs)
        self.s = s
        self.are = are
    def s_form(self,s):
        self.s = (self.a+self.b+self.c)/2
    def area(self,are):
        self.are = (self.s*(self.s-self.a)*(self.s-self.b)*(self.s-self.c)) * 0.5
    def __str__(self):
        return "Area of the given triangle is: {}".format(self.are)
s = 0
are = 0
obj = Area(s,are,3,4,5)
obj.a
obj.b
obj.c
obj.s_form(s)
print(obj.s)
obj.area(are)
obj.__str__()<jupyter_output><empty_output><jupyter_text>1.2Write a function filter_long_words() that takes a list of words and an integer n and returns the listof words that are longer than n.<jupyter_code>a = []
x = int(input("Enter x:"))
for i in range(x):
    temp = input()
    a.append(temp)
n = int(input("Enter the limit: "))
ans = list(filter(lambda strx:len(strx)>n,a))
ans<jupyter_output><empty_output><jupyter_text>2.1Write a Python program using function concept that maps list of words into a list of integersrepresenting the lengths of the corresponding words .Hint: If a list [ ab,cde,erty] is passed on to the python function output should come as [2,3,4]Here 2,3 and 4 are the lengths of the words in the list.<jupyter_code>a = []
x = int(input("Enter x:"))
for i in range(x):
    temp = input()
    a.append(temp)
ans = list(map(lambda a:len(a),a))
ans<jupyter_output><empty_output><jupyter_text>2.2Write a Python function which takes a character (i.e. a string of length 1) and returns True if it isa vowel, False otherwise.<jupyter_code>a = ["a","e","i","o","u"]

def isvowel(arg1):
    for i in a:
        if arg1==i:
            return True
    return False
arg1 = input("Enter a character: ")
arg2 = input("Enter a character: ")
isvowel(arg1)
isvowel(arg2)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup