Assignment-6 ============ 1.Chef is a software developer, so he has to switch between different languages sometimes. Each programming language has some features, which are represented by integers here. Currently, Chef has to use a language with two given features A and B. He has two options --- switching to a language with two features A1 and B1, or to a language with two features A2 and B2. All four features of these two languages are pairwise distinct. Tell Chef whether he can use the first language, the second language or neither of these languages (if no single language has all the required features) The first and only line of each test case contains six space-separated integers A,B,A1,B1,A2,B2. For each test case, print a single line containing the integer 1 if Chef should switch to the first language, or 2 if Chef should switch to the second language, or 0 if Chef cannot switch to either language. Ans:- ===== NoOfTestCases = int(input()) for i in range(NoOfTestCases): A,B,A1,B1,A2,B2 = map(int, input("Please provide A B A1 B1 A2 B2 space seperated values :").split()) if ((A==A1 and B==B1) or (A==B1 and B==A1)): print(1) elif((A==A2 and B==B2) or (A==B2 and B==A2)): print(2) else: print(0) Output:- ========   3 Please provide A B A1 B1 A2 B2 space seperated values : 1 2 2 1 3 4 1 Please provide A B A1 B1 A2 B2 space seperated values : 2 3 1 2 2 3 2 Please provide A B A1 B1 A2 B2 space seperated values : 1 2 2 1 1 2 1 ================================================================================== 2.You have prepared four problems. The difficulty levels of the problems are A1,A2,A3,A4 respectively. A problem set comprises two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Find the maximum number of problem sets you can create using the four problems. Each test case contains four space-separated integers A1, A2, A3, A4, denoting the difficulty level of four problems. For each test case, print a single line containing one integer - the maximum number of problem sets you can create using the four problems. Ans:- ===== noOfTestCases = int(input()) for i in range(noOfTestCases): l = list(map(int, input().split())) a = set(l) if (len(a) == 4): print(2) elif (len(a) == 3): print(2) elif (len(a) == 2): l.sort() b = l[0] if(l.count(b) == 2): print(2) else: print(1) else: if(len(a) > 4): print("Please provide valid set of data with 4 difficulty levels!") else: print(0) Output :- =========   3 2 3 4 5 2 2 3 1 1 2 3 4 5 Please provide valid set of data with 4 difficulty levels! ========================================================================================= 3. Develop a python code to check given two dates d1 and d1 , check whether d1 is less than d2 or d1 is greater than d2 or d1 is equal to d2. (Hint: overload < , > , == operators) Ans:- ===== import datetime d1 = datetime.datetime(2022, 11, 17) d2 = datetime.datetime(2022, 12, 10) print("d1 is greater than d2 : ", d1 > d2) print("d1 is less than d2 : ", d1 < d2) print("d1 is not equal to d2 : ", d1 != d2) Output:- ========   d1 is greater than d2 : False d1 is less than d2 : True d1 is not equal to d2 : True ========================================================================================================= 4. Develop python code to add, subtract , multiply and divide two distances where each distance contains two things of the format KM followed by Meters. (Example: d1 = 4km 500 m and d2 = 3 km 200 m ) Ans:- ===== def conver_km_to_m(km): km = float(km) m = km * 1000 return m def conver_m_to_km(m): km = int(m/1000) m = m%1000 return str(km) + " km "+str(m)+" m" d1K,d1M = map(float, input("Please select d1 (km m) value with space").split()) d2K,d2M = map(float, input("Please select d2 (km m) value with space").split()) d1 = conver_km_to_m(d1K) + d1M d2 = conver_km_to_m(d2K) + d2M print("Add : ",conver_m_to_km(d1+d2)) print("SUB : ",conver_m_to_km(d1-d2)) print("MUL : ",conver_m_to_km(d1*d2)) print("DIV : ",conver_m_to_km(d1/d2)) Output:- ========   Please select d1 (km m) value with space 2 200 Please select d2 (km m) value with space 1 100 Add : 3 km 300.0 m SUB : 1 km 100.0 m MUL : 2420 km 0.0 m DIV : 0 km 2.0 m =================================================================================== 5. Develop a class called Box with attributes length, breadth, depth and define required constructor and other relevant methods. Inherit Box class to WeightBox which contains extra attribute as weight. From this extent further as ColorWeightBox which has Color as extra attribute. Develop code for entire scenario using multi-level inheritance. Ans:- ===== class Box: def __init__(self,l,b,d): self.l=l self.b=b self.d=d self.v = 0 self.w = 0 def volume(self): self.v = self.l*self.b*self.d #return(self.l*self.b*self.d) class WeightBox(Box): def WeightBox(self): self.w = "100kg" class ColorWeightBox(WeightBox): def ColorWeightBox(self): self.c = "Black" print("Volume : ",self.v) print("Weight of Volume : ",self.w) print("Color of Volume : ",self.c) b1 = ColorWeightBox(10,20,30) b1.volume() b1.WeightBox() b1.ColorWeightBox() Output:- ========   Volume : 6000 Weight of Volume : 100kg Color of Volume : Black