count1 = 1
while(count1<=5):
count1 += 1
count2 = 0
count2 += 1
print "count1 = %d count2 = %d " %(count1, count2)
print "count1 = %d\n" %count1
count = 0
while(count<=5):
count += 1
print "count = ", count
print "count = ", count
def Sum(x, n):
sum = 0.0
for i in range(n):
sum += x[i]
return sum
def Average(x, n):
return Sum(x, n)/n
def GetData(data, t):
print "How many values do you want to enter (Maximum 50)? "
nValues = int(raw_input())
if(nValues > 50):
print "Maximum count exceeded. 50 items will be read."
nValues = 50
for i in range(nValues):
data.append(float(raw_input()))
return nValues
samples = []
sampleCount = GetData(samples, 50);
average = Average(samples, sampleCount);
print "The average of the values you entered is: ", average
def sort_string(text):
dot_separated = text.split('.')
text_sorted = sorted(dot_separated)
return text_sorted
print "Enter strings to be sorted, separated by '.' Press Enter to end: "
text = raw_input()
sorted_text = sort_string(text)
for str in sorted_text:
print str
def IncomePlus(pPay):
pPay += 10000
return pPay
your_pay = 30000
pold_pay = your_pay
pnew_pay = IncomePlus(pold_pay)
print "Old pay = $", pold_pay
print "New pay = $", pnew_pay
def IncomePlus(pPay):
pPay += 10000
return id(pPay)
your_pay = 30000
pold_pay = your_pay
pnew_pay = IncomePlus(pold_pay)
print "Old pay = $", pold_pay
print "New pay = $", pnew_pay