#Declarations
iNoOfDays = 31
dSum = 0
dblTempApr=[[0 for col in range(31)] for row in range(31)]
#Entry and calculation
for i in range(1,iNoOfDays):
dblTempApr[i] = raw_input("Temperature Day %d: " % i)
dSum += dblTempApr[i]
dAvg = dSum / iNoOfDays
#Printout
print "Average temperature: %f" % dAvg
print "Temperatures exceeding average: "
for i in range(1,iNoOfDays):
if (dblTempApr[i] > dAvg):
print "Day no.: %d" % i,
print " temp: %d" % dblTempApr[i]
#Declaration
iMaxNo = 100
dLimit = 5000
perc1 = 0.1
perc2 = 0.15
sales = [[0 for col in range(1)] for row in range(iMaxNo)]
#Initialize array
for i in range(0,iMaxNo):
sales[i] = 0
#Enter Salesman info
nr=input("Enter Salesman no. : ")
dAmount=input("Enter sales amount: ")
while (nr and dAmount):
if(nr<1 or nr>iMaxNo or dAmount<0):
print "Input error"
break;
else:
sales[nr-1]+= dAmount
nr=int(raw_input("Enter Salesman no. : "))
dAmount=float(raw_input("Enter sales amount: "))
#Print summary
print "Number Amount Fee"
print "====== ====== ==="
for i in range(0,iMaxNo):
if (sales[i] > 0):
if(sales[i] <= dLimit):
dFee = perc1 * sales[i]
else:
dFee = perc1 * dLimit + perc2*(sales[i] - dLimit)
j=i;
j=j+1;
print "%4d" % j,
print "%13d" % sales[i],
print "%10.0f" % dFee
#Declaration
l=0
r=30
iFound=0
# Array is in sorted form
iProdid= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
iSrch = raw_input("Enter the searched product id: ")
if(iSrch == iProdid[0]):
iPos = 0
iFound= 1
if (iSrch == iProdid[30]):
iPos = 30
iFound = 1
while not (iFound):
iMid = (int)(l + ((r-l)/2))
if(iSrch == iProdid[iMid]):
iFound = 1
iPos = iMid
if(iSrch > iProdid[iMid]):
l=iMid
else:
r=iMid