PROGRAM TO PRINT THE DIFFERENCE BETWEEN THE LENGTH OF THE RECTANGLES:
STATEMENT:
Alen and Tim both own a tennis grass court and they decide to mow the lawn in and around the court which will cost them Rs.5 per square feet. Given the amount they spent to mow the lawn and the width of the court, find the difference between the length of the courts.
PROGRAM:
amounts = input().strip().split(" ")
widths = input().strip().split(" ")
amountAlen = int(amounts[0])
amountTim = int(amounts[1])
widthAlen = int(widths[0])
widthTim = int(widths[1])
lengthAlen = amountAlen/(5*widthAlen)
lengthTim = amountTim/(5*widthTim)
diff = abs(lengthAlen-lengthTim)
print ("%.2f" %diff)
Input:
17500 40000
50 80
Output:
30.00
Explanation:
Area of Alen's court = 17500/5 = 3500 sq.ft. Length = 3500/50 = 70
Area of Tim's court = 40000/5 = 8000 sq.ft. Length = 8000/80 = 100
Hence the difference = 100-70 = 30.00
PROGRAM TO CONCATENATE STRING ALPHABETICALLY:
STATEMENT:
Two string values S1 and S2 are passed as the input. The program must concatenate them depending on which string comes first in the alphabetical order.
PROGRAM:
s1 = input().strip()
s2 = input().strip()
values = [s1,s2]
values.sort()
for s in values:
print (s, end="")
Input:
zoo
tiger
Output:
tigerzoo
STATEMENT:
Alen and Tim both own a tennis grass court and they decide to mow the lawn in and around the court which will cost them Rs.5 per square feet. Given the amount they spent to mow the lawn and the width of the court, find the difference between the length of the courts.
PROGRAM:
amounts = input().strip().split(" ")
widths = input().strip().split(" ")
amountAlen = int(amounts[0])
amountTim = int(amounts[1])
widthAlen = int(widths[0])
widthTim = int(widths[1])
lengthAlen = amountAlen/(5*widthAlen)
lengthTim = amountTim/(5*widthTim)
diff = abs(lengthAlen-lengthTim)
print ("%.2f" %diff)
Input:
17500 40000
50 80
Output:
30.00
Explanation:
Area of Alen's court = 17500/5 = 3500 sq.ft. Length = 3500/50 = 70
Area of Tim's court = 40000/5 = 8000 sq.ft. Length = 8000/80 = 100
Hence the difference = 100-70 = 30.00
PROGRAM TO CONCATENATE STRING ALPHABETICALLY:
STATEMENT:
Two string values S1 and S2 are passed as the input. The program must concatenate them depending on which string comes first in the alphabetical order.
PROGRAM:
s1 = input().strip()
s2 = input().strip()
values = [s1,s2]
values.sort()
for s in values:
print (s, end="")
Input:
zoo
tiger
Output:
tigerzoo
No comments:
Post a Comment