So here we are packing objects and Both Length, Width and Height of object should be less than 50 for a good case and if any is more than 50 then the case is bad. I have written my program below but all cases are judged by the last case.
Sample input
2
20 20 20
1 2 51
Sample output
Case 1: good
Case 2: bad
T = int(input("Enter the number of test cases:\n"))
for i in range(1,T+1):
print("Enter the values of the Length, Width, Height")
case = input()
#Length_1.
if case[1] == " ":
L = int(case[0])
#Width and heigth.
if case[3] == " " and len(case) == 5:
W = int(case[2])
H = int(case[4])
if case[4] == " " and len(case) == 6:
W = int(case[2:4])
H = int(case[5])
if case[3] == " " and len(case) == 6:
W = int(case[2])
H = int(case[4:6])
if case[4] == " " and len(case) == 7:
W = int(case[2:4])
H = int(case[5:7])
#Length_2.
if case[2] == " ":
L = int(case[0:2])
#Width and height.
if case[4] == " " and len(case) == 6:
W = int(case[3])
H = int(case[5])
if case[5] == " " and len(case) == 7:
W = int(case[3:5])
H = int(case[6])
if case[4] == " " and len(case) == 7:
W = int(case[3])
H = int(case[5:7])
if case[5] == " " and len(case) == 8:
W = in`enter code here`t(case[3:5])
H = int(case[6:8])
for i in range(1,T+1):
if L > 50 or W > 50 or H > 50:
print("Case ", i,":"," bad", sep='')
else:
print("Case ", i,":"," good", sep='')
Aucun commentaire:
Enregistrer un commentaire