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.
T = int(input("Enter the number of test cases:"))
for i in range(T):
A,B,A1,B1,A2,B2 = map(int,input().split())
max_ab = max(A,B)
min_ab = min(A,B)
max_a1b1 = max(A1,B1)
min_a1b1 = min(A1,B1)
max_a2b2 = max(A2,B2)
min_a2b2 = min(A2,B2)
if ((max_ab == max_a1b1) and (min_ab == min_a1b1)):
print(1)
elif ((max_ab == max_a2b2) and (min_ab) == min_a2b2):
print(2)
else:
print(0)
Enter the number of test cases:3 1 2 2 1 3 4 1 3 4 2 1 4 3 2 1 2 1 3 2 4 0
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.
Test_cases = int(input("Enter no. of test cases to be conducted: "))
for i in range(Test_cases):
l = list(map(int,input().split()))
s = set(l)
if (len(s) == 4):
print(2)
elif (len(s) == 3):
print(2)
elif (len(s) == 2):
l.sort()
a = l[0]
if (l.count(a) == 2):
print(2)
else:
print(1)
else:
print(0)
Enter no. of test cases to be conducted: 3 1 4 3 2 2 4 5 5 5 1 2 2 2 2 0
class Date:
def __init__(self,d,m,y):
self.d = d
self.m = m
self.y = y
def display(self):
print(self.d,"/",self.m,"/",self.y)
def __eq__(self,da):
if(self.d == da.d and self.m == da.m and self.y == da.y):
return(True)
else:
return(False)
def __gt__(self,db):
if((self.d >= db.d and self.m >= db.m and self.y >= db.y) or (self.d <= db.d and self.m >= db.m and self.y >= db.y) or (self.d <= db.d and self.m <= db.m and self.y >= db.y)):
return(True)
else:
return(False)
d1 = Date(2,12,2005)
d1.display()
d2 = Date(22,10,2004)
d2.display()
if(d1 == d2):
print("Equal")
elif(d1 > d2):
print("d1 is greater than d2")
else:
print("d2 is greater than d1")
2 / 12 / 2005 22 / 10 / 2004 d1 is greater than d2
d1_km,d1_m = map(int,input("Enter first distance in KM and Meters: ").split())
d2_km,d2_m = map(int,input("Enter second distance in KM and Meters:").split())
d1 = print("d1 =",d1_km,"km",d1_m,"m" )
d2 = print("d2 =",d2_km,"km",d2_m,"m")
result = 0
d_1 = (d1_km * 1000) + d1_m
d_2 = (d2_km * 1000) + d2_m
ch = input("Enter any of the operation +,-,*,/: ")
if ch == "+":
result = d_1 + d_2
print(f"Distance = {result} m")
elif ch == "-":
result = d_1 - d_2
print(f"Distance = {result} m")
elif ch == "*":
result = d_1 * d_2
print(f"Distance = {result} m")
elif ch == "/":
result = d_1 / d_2
print(f"Distance = {result} m")
else:
print("Error Operation")
Enter first distance in KM and Meters: 2 121 Enter second distance in KM and Meters:3 211 d1 = 2 km 121 m d2 = 3 km 211 m Enter any of the operation +,-,*,/: * Distance = 6810531 m
class Box:
def __init__(self,l,b,d):
self.l = l
self.b = b
self.d = d
def display(self):
print("Parameters of box are: ")
print("Length:",self.l)
print("Breadth:",self.b)
print("Depth:",self.d)
class WeightBox(Box):
def __init__(self,l,b,d,weight):
Box.__init__(self,l,b,d)
self.weight = weight
def display(self):
Box.display(self)
print("Weight:",self.weight)
class ColorWeightBox(WeightBox):
def __init__(self,l,b,d,weight,color):
WeightBox.__init__(self,l,b,d,weight)
self.color = color
def display(self):
WeightBox.display(self)
print("Color:",self.color)
box = ColorWeightBox(30,20,2,50,"Red")
box.display()
Parameters of box are: Length: 30 Breadth: 20 Depth: 2 Weight: 50 Color: Red